Caching app block questions.

Topics: Caching Application Block , General discussion
Jan 11, 2008 at 10:11 AM
Edited Jan 11, 2008 at 10:27 AM
Hi,
I'm using caching application block in a report applicacion (the application use smart client software factory scsf).
I use cache for complex large objects with the data I get from database and I use this objects as source of a grid ( When a user execute a report, a complex sql is executed, then I cached the result of the sql execution, and the next time (same day, another day) the user execute that report, no sql is executed because it is already cached and the response of the aplication is better)
I have some question I would like someone could resolve.

My xml configuration file is:
<cachingConfiguration defaultCacheManager="EssbaseReportCache">
<cacheManagers>
<add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="50"
numberToRemoveWhenScavenging="10" backingStoreName="Report Storage"
name="EssbaseReportCache" />
</cacheManagers>
<backingStores>
<add partitionName="EssbaseReportStorage" encryptionProviderName=""
type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
name="Report Storage" />
</backingStores>
</cachingConfiguration>


1- I'm using isolated storage, but where the data is stored, in which directory or which file is used for it?. I can change the localization of this file? How? It's used a file for each object that I add to cache or one file for all objects? I can use one xml file for each object I add to cache?

2- The method to create the object CacheManager is slow in my case. I think a lot of data is load to memory when I create the object CacheManager:
CacheManager Cache = CacheFactory.GetCacheManager("EssbaseReportCache");
There is a way in which the cache only load in memory a map of objects that there are in the cache and no all the cache objects (because this is slow if the objects are large).

3- Sometimes I get this exception in the method GetCacheManager:
Could not find file 'EssbaseReportStorage\-588029326\Key'.
Why? How can I resolve it?

Sorry by my english

Thanks


--------------------------------- Spanish ---------------------------------------
Buenos días,

Tengo una aplicacion que usa el Caching application block ademas del smart client software factory.
Uso la cache para almacenar datos de informes que recupero de complejas sentencias sql y de esta forma evitar ejecutar dos veces la misma sentencia sql si un usuario ejecuta dos veces el mismo informe (de esta forma la respuesta de la aplicación la segunda vez es mucho mas rapida).

Las cuestiones que se me presentan son:

1-Donde se almacenan los datos que introduzco en la cache? En que directorio o en que fichero o ficheros? Se podría indicar que por cada objeto en la cache se crease un fichero distinto que lo almacenase (es posible que fuese en formato xml)?

2- El metodo para obtener el CacheManager es lento en mi caso (creo que hay muchos datos que cargar en memoria). Hay alguna forma de que esta carga de la cache sea mas optima, por ejemplo, en lugar de cargar todos los datos de la cache (que creo que es lo que hace) cargar un mapa con la clave y la direccion en la que esta el objeto y cuando recupero ese objeto, sea en ese momento cuando cargue el obeto en memoria y acceda a disco.

3- A verces obtengo esta excepcion en el metodo GetCacheManager:
Could not find file 'EssbaseReportStorage\-588029326\Key'.
Alguien sabe porque? Hay alguna forma de solucionarlo?


Gracias
Jan 15, 2008 at 1:04 AM
Answers inline


1- I'm using isolated storage, but where the data is stored, in which directory or which file is used for it?. I can change the localization of this file? How? It's used a file for each object that I add to cache or one file for all objects? I can use one xml file for each object I add to cache?

The location of the isolated storage is an implementation detail. The partitionName setting is used to specify a location relative to the isolated storage root, but not the actual folder.


2- The method to create the object CacheManager is slow in my case. I think a lot of data is load to memory when I create the object CacheManager:
CacheManager Cache = CacheFactory.GetCacheManager("EssbaseReportCache");
There is a way in which the cache only load in memory a map of objects that there are in the cache and no all the cache objects (because this is slow if the objects are large).

No. The way it is designed, the cache will store the complete contents in memory.


3- Sometimes I get this exception in the method GetCacheManager:
Could not find file 'EssbaseReportStorage\-588029326\Key'.
Why? How can I resolve it?


Does the exception bubble up to your code? Please post a stack trace for the exception.

Regards,
Fernando
Jan 15, 2008 at 6:44 AM
Thanks Fernando.

This week it doesn't throw that exception but this is the entry in the "visor de sucesos" (Sorry, I don't know how it is said in english):

Timestamp: 11-01-2008 13:58:46
Message: HandlingInstanceID: ad01c785-5539-411b-a8b0-e284b6f130c9
An exception of type 'System.IO.FileNotFoundException' occurred and was caught.
-------------------------------------------------------------------------------
01/11/2008 14:58:46
Type : System.IO.FileNotFoundException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Could not find file 'EssbaseReportStorage\-588029326\Key'.
Source : mscorlib
Help link :
FileName : EssbaseReportStorage\-588029326\Key
FusionLog :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void WinIOError(Int32, System.String)
Stack Trace : at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, IsolatedStorageFile isf)
at Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageCacheItemField.Read(Boolean encrypted)
at Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageCacheItem.Load()
at Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageBackingStore.LoadDataFromStore()
at Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.BaseBackingStore.Load()
at Microsoft.Practices.EnterpriseLibrary.Caching.Cache..ctor(IBackingStore backingStore, CacheCapacityScavengingPolicy scavengingPolicy, CachingInstrumentationProvider instrumentationProvider)
at Microsoft.Practices.EnterpriseLibrary.Caching.CacheManagerFactoryHelper.BuildCacheManager(String cacheManagerName, IBackingStore backingStore, Int32 maximumElementsInCacheBeforeScavenging, Int32 numberToRemoveWhenScavenging, Int32 expirationPollFrequencyInSeconds, CachingInstrumentationProvider instrumentationProvider)
at Microsoft.Practices.EnterpriseLibrary.Caching.CacheManagerCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)
at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) in C:\Archivos de programa\Microsoft Composite UI App Block\CSharp\Source\ObjectBuilder\BuilderStrategy.cs:line 39
at Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) in C:\Archivos de programa\Microsoft Composite UI App Block\CSharp\Source\ObjectBuilder\Strategies\Singleton\SingletonStrategy.cs:line 48
at Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) in C:\Archivos de programa\Microsoft Composite UI App Block\CSharp\Source\ObjectBuilder\BuilderStrategy.cs:line 39
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationNameMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) in C:\Archivos de programa\Microsoft Composite UI App Block\CSharp\Source\ObjectBuilder\BuilderBase.cs:line 101
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) in C:\Archivos de programa\Microsoft Composite UI App Block\CSharp\Source\ObjectBuilder\BuilderBase.cs:line 79
at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUpTTypeToBuild(IReadWriteLocator locator, String idToBuild, Object existing, PolicyList[] transientPolicies) in C:\Archivos de programa\Microsoft Composite UI App Block\CSharp\Source\ObjectBuilder\BuilderBase.cs:line 66
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUpT(IReadWriteLocator locator, String id, IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.LocatorNameTypeFactoryBase`1.Create(String name)
at Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.GetCacheManager(String cacheManagerName)
at DataMartRentabilidad.QueryModule.ServiceProxies.Services.ReportService.CreateReportCache() in C:\FrontRentabilidad\Sistema de Rentabilidad de Clientes (SRC)\SISTEMA DE RENTABILIDAD DE CLIENTES (SRC)\QueryModule\QueryModule.ServiceProxies\QueryModule.ServiceProxies\Services\ReportService.cs:line 82
Jan 15, 2008 at 8:40 AM
I see from your config file you're using EntLib Jan 2006. A work around for this issue was implemented for the April 2007 version; you may want to consider upgrading or applying that change to the EntLib source tree you're using (class IsolatedStorageBackingStore, method LoadData).

Fernando