Class AttributeCache
Cache manager for attribute resolver data.
Provides caching with optional file validation to ensure cached attribute metadata is still fresh.
Property Summary
-
$cache protected
Psr\SimpleCache\CacheInterfaceCache interface instance
Method Summary
-
__construct() public
Constructor.
-
cacheKey() protected
Generate cache key for a resolver configuration.
-
delete() public
Delete cached attribute data.
-
isValid() protected
Validate that cached data is still fresh by checking source file modification times.
Compares each source file's current modification time against the stored fileTime from when the cache was created. If any source file is newer, the cache is stale.
-
read() public
Read attribute data from cache.
-
write() public
Write attribute data to cache.
Stores as raw arrays with pre-built indexes for optimal cache performance. Uses AttributeCollection::getCacheData() to convert objects to arrays.
Method Detail
__construct() ¶ public
__construct(string $cacheConfig, bool $validateFiles = false)
Constructor.
Parameters
-
string$cacheConfig Name of the cache configuration to use
-
bool$validateFiles optional Whether to validate source file modification times
cacheKey() ¶ protected
cacheKey(string $name): string
Generate cache key for a resolver configuration.
Parameters
-
string$name Resolver configuration name
Returns
stringCache key
delete() ¶ public
delete(string $name): bool
Delete cached attribute data.
Parameters
-
string$name Resolver configuration name
Returns
boolSuccess
isValid() ¶ protected
isValid(array<array<string, mixed>> $data): bool
Validate that cached data is still fresh by checking source file modification times.
Compares each source file's current modification time against the stored fileTime from when the cache was created. If any source file is newer, the cache is stale.
Parameters
-
array<array<string, mixed>>$data Cached raw array data
Returns
boolTrue if valid, false if any source file has changed
read() ¶ public
read(string $name): Cake\AttributeResolver\AttributeCollection|null
Read attribute data from cache.
Parameters
-
string$name Resolver configuration name
Returns
Cake\AttributeResolver\AttributeCollection|nullAttributeCollection or null if not found/invalid
write() ¶ public
write(string $name, Cake\AttributeResolver\AttributeCollection|array<Cake\AttributeResolver\ValueObject\AttributeInfo> $data): bool
Write attribute data to cache.
Stores as raw arrays with pre-built indexes for optimal cache performance. Uses AttributeCollection::getCacheData() to convert objects to arrays.
Parameters
-
string$name Resolver configuration name
-
Cake\AttributeResolver\AttributeCollection|array<Cake\AttributeResolver\ValueObject\AttributeInfo>$data AttributeInfo objects to cache
Returns
boolSuccess