Contextual Image Delivery Administration API

Use the CID Administration API to retrieve caching statistics and to remove items from the image transformation caches. By default, the on-disk cache will only be filled after reaching the maximum number of in-memory cache entries. When this happens, by default, all on-disk cache entries and the least recently used in-memory cache entries are persisted. You can change this default behavior through configuration.

Creating a CID caching statistics object

Use the CID administrator class to get a statistics object which can access all the methods and properties described below.

Java
import com.sdl.context.image.api.admin.ContextualImageDeliveryAdministrator;
import com.sdl.context.commons.api.caching;
...
@Autowired
private ContextualImageDeliveryAdministrator contextualImageDeliveryAdministrator;
CacheStatistics statistics = contextualImageDeliveryAdministrator.getStatistics();
.NET
using Tridion.Context.Image.Api.Admin;
using Tridion.Context.Commons.Api.Caching
...
ICacheStatistics statistics = ContextualImageDeliveryAdministrator.Instance.Statistics;

Caching statistics

Java method.NET propertyReturn typeMethod returns...
getCacheHitRatio()CacheHitRatiodoublethe cache hit ratio
getLocalHeapHitCount()LocalHeapHitCountlongthe numbers of entries returned from in-memory cache.
getLocalHeapMissCount()LocalHeapMissCountlongthe numbers of entries that could not be found in in-memory cache.
getLocalHeapSize()LocalHeapSizelongthe numbers of entries currently in in-memory cache.
getLocalDiskHitCount()LocalDiskHitCountlongthe numbers of entries returned from on-disk cache.
getLocalDiskMissCount()LocalDiskMissCountlongthe numbers of entries that could not be found in on-disk cache.
getLocalDiskSize()LocalDiskSizelongthe numbers of entries currently in on-disk cache.

Removing items from the cache

The CID cache stores transformed images and their timestamps. You can remove these cache entries using the following methods.

MethodDescriptionExample
removeAll()Remove all items in the cacheadmin.removeAll();
remove()
Remove all items that were transformed from source URLs matching one of the following:
  • A string containing a single * character (representing any sequence of 0 or more characters except /, the forward slash) and/or the string ** (representing any sequence of 0 or more characters)
Example of each:
  • admin.remove("http://www.example.com/**");
  • admin.remove("/^http://www\.example\.com/.*$/");

Instead of a literal string, you can also include one or both of the following wildcard characters in the string:

WildcardDescription
*Represents any sequence of 0 or more characters except /, the forward slash.
**Represents any sequence of 0 or more characters.