CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 6.0 API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 6.0
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • AttributeResolver
      • ValueObject
    • Cache
    • Collection
    • Command
    • Console
    • Container
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Lock
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class AttributeCache

Cache manager for attribute resolver data.

Provides caching with optional file validation to ensure cached attribute metadata is still fresh.

Namespace: Cake\AttributeResolver

Property Summary

  • $cache protected
    Psr\SimpleCache\CacheInterface

    Cache 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
string

Cache key

delete() ¶ public

delete(string $name): bool

Delete cached attribute data.

Parameters
string $name

Resolver configuration name

Returns
bool

Success

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
bool

True 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|null

AttributeCollection 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
bool

Success

Property Detail

$cache ¶ protected

Cache interface instance

Type
Psr\SimpleCache\CacheInterface
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs