CacheKeyExists()

edit

this function is deprecated, use instead CacheIdExists().

Returns true/false whether the cache contains an element with the certain keyname.

Status:

deprecated

CacheKeyExists( key=string, cacheName=string );

Returns: Boolean

Argument Description
key
string, required
edit

key to check

Alias: name, id

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( "myKey", "hello" );
// NOTE: cacheKeyExists is deprecated — use cacheIdExists() instead
dump( cacheKeyExists( "myKey" ) );    // true
dump( cacheKeyExists( "noSuchKey" ) ); // false
// same thing with the recommended function
dump( cacheIdExists( "myKey" ) );      // true

See also