---
title: "Problem med cache"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/97820-problem-med-cache"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "Jon"
published: "2004-02-20T17:49:06.000Z"
updated: "2004-02-20T17:49:06.000Z"
replies: 0
views: 165
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/97820-problem-med-cache"
---

# Problem med cache

## #1 — Jon, 2004-02-20T17:49Z

Försöker använda Microsoft.ApplicationBlocks.Cache Men när jag försöker hämta ett objekt som jag lagt på chachen så finns det inte.

Instantierar så här

```
CacheManager cm = CacheManager.GetCacheManager();
```

Lägger till

```
cm.Add(objType.ToString() + keyValue.ToString(),result);
```

Hämtar

```
object result = cm.GetData(objType.ToString() + keyValue.ToString());
```

web.config

```
<configSections>
    <section name="CacheManagerSettings" type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler,Microsoft.ApplicationBlocks.Cache" />
</configSections>

<CacheManagerSettings>

            <DataProtectionInfo AssemblyName="Microsoft.ApplicationBlocks.Cache"
				ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.DefaultDataProtection"
				ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAFnssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
				Validation="SHA1"/>                                                                 

            <StorageInfo AssemblyName="Microsoft.ApplicationBlocks.Cache"
				ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCacheStorage"
				Mode="InProc"
				Validated="true"
				Encrypted="true"/>

            <!-- SCAVENGING SETTINGS
            Use the ScavengingAlgorithm to set a class that will be executed when
            scavenging is performed.
            -->

            <ScavengingInfo AssemblyName="Microsoft.ApplicationBlocks.Cache"
				ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScavenging"
				MemoryPollingPeriod="60"
				UtilizationForScavenging="80"
				MaximumSize="5"/>

            <!-- EXPIRATION SETTINGS
            Use the ExpirationCheckInterval to change the interval to check for 
            cache items expiration. The value attribute is represented in seconds.
            
            <ExpirationInfo Interval="1" />-->
            <ExpirationInfo Interval="120" />
      </CacheManagerSettings>
</configSections>
```

Jag har fått för mig att det ska funka som ett singelton-objekt om man konfar så. Är det fel?

I så fall ska ju cachen skapas vid första anropet och senad returneras vid följande anrop.

Finns det något bra sätt att kolla alla objekt i chachen?

Permalänk: https://www.webforum.nu/p/97820

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/97820-problem-med-cache
