CacheCount()
Returns the amount (integer) of keys stored in the cache.
CacheCount( cacheName=string );
Returns: Number
| Argument | Description |
|---|---|
|
cacheName
string,
optional
|
edit
definition of the cache used by name, when not set the "default Object Cache" defined in Lucee Administrator is used instead. Alias: cache, region |
Examples
edit// define a RAM cache as the default object cache
application action="update" caches="#{ trycf: {
class: 'lucee.runtime.cache.ram.RamCache',
custom: { timeToIdleSeconds: 3600, timeToLiveSeconds: 3600 },
default: 'object'
}}#";
cacheClear();
// empty cache
dump( cacheCount() ); // 0
cachePut( "key1", "value1" );
cachePut( "key2", "value2" );
cachePut( "key3", "value3" );
dump( cacheCount() ); // 3
// you can also count entries in a specific named cache
dump( cacheCount( "trycf" ) ); // 3
See also
- Cache
- Getting Started with Caching
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)