CacheGetAllIds()
this function return an array containing all keys inside the cache.
CacheGetAllIds( filter=string, cacheName=string );
Returns: Array
| Argument | Description |
|---|---|
|
filter
string,
optional
|
edit
key filter for the elements, the filter follow the same rules as for cfdirectory-filter. |
|
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();
cachePut( "fruit:apple", "red" );
cachePut( "fruit:banana", "yellow" );
cachePut( "vehicle:car", "blue" );
// returns an array of all cache keys (uppercase)
ids = cacheGetAllIds();
dump( ids ); // ["FRUIT:APPLE", "FRUIT:BANANA", "VEHICLE:CAR"]
// use a wildcard filter to get a subset
fruitIds = cacheGetAllIds( "fruit:*" );
dump( fruitIds ); // ["FRUIT:APPLE", "FRUIT:BANANA"]
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)