Data Cache

ImageVault utilizes a cache layer in front of the database. This is configured using the setup or directly in the web.config file.

There are two types of data caches; in-process and out-of-process.

In-process cache

This is a simple memory cache that caches data inside the web process. Only suitable for single instance installations. ImageVault provides the HttpRuntimeObjectCache as an in-process cache.

Out-of-process cache

This cache stores the data outside the instance process and is suitable if you run multiple instances of the same ImageVault application. This is primarily used in load balancing scenarios. ImageVault provides the RedisObjectCache as an out-of-process cache.

HttpRuntimeObjectCache (in-process)

This is the default setting and will be used if no other configuration is found. This cache is an in-process cache and utilizes the Http runtime cache of the web process. It is recommended when you only have one ImageVault instance and don't need to keep the cache in sync with other instances.

Configuration

This cache does not need any configuration since it's the default if no other cache configuration is found but you can explicitly configure it as the example below.

<imagevault.common>
    <objectCache defaultProvider="HttpRuntimeObjectCache">
        <providers>
            <add name="HttpRuntimeObjectCache" type="ImageVault.Common.Data.Caching.HttpRuntimeObjectCache,ImageVault.Common" />
        </providers>
    </objectCache>
</imagevault.common>

RedisObjectCache (out-of-process)

The Redis object cache is an out-of-process cache and requires a Redis cache instance. This cache is recommended when several ImageVault instances are connected to the same database and need to keep the cache updated between themselves.

Configuration

To utilize the redis object cache you need to specify the redis connection string and the cache provider.

<connectionStrings>
    <add name="RedisCache" connectionString="mycache.redis.cache.windows.net:6380,password=someSecretPassword,ssl=True,abortConnect=False" />
</connectionStrings>
<imagevault.common>
    <objectCache defaultProvider="RedisObjectCache">
        <providers>
            <add name="RedisObjectCache" type="ImageVault.Core.Platform.RedisObjectCache,ImageVault.Core.Platform" />
        </providers>
    </objectCache>
</imagevault.common>

You can also configure multiple ImageVault installations that uses different databases to use the same Redis cache instance. In that case you must configure the cachePrefix to be unique for each set of ImageVault instances that uses the same database.

Redis

The Redis cache is a third party application that is used by the RedisOutputCache handles the out-of process cache. It can either be downloaded from the redis.io site and installed manually or you can buy an online azure instance.

comments powered by Disqus