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 3.10 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.10
      • 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
    • Auth
    • Cache
      • Engine
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Class SimpleCacheEngine

Wrapper for Cake engines that allow them to support the PSR16 Simple Cache Interface

Namespace: Cake\Cache
Link: https://www.php-fig.org/psr/psr-16/

Property Summary

  • $innerEngine protected
    Cake\Cache\CacheEngine

    The wrapped cache engine object.

Method Summary

  • __construct() public

    Constructor

  • add() public

    Write data for key into a cache engine if it doesn't exist already.

  • clear() public

    Wipes clean the entire cache's keys.

  • clearGroup() public

    Clear all values belonging to the named group.

  • decrement() public

    Decrement a number under the key and return decremented value

  • delete() public

    Delete an item from the cache by its unique key.

  • deleteMultiple() public

    Deletes multiple cache items in a single operation.

  • ensureValidKey() protected

    Ensure the validity of the given cache key.

  • ensureValidKeys() protected

    Ensure the validity of the given cache keys.

  • get() public

    Fetches the value for a given key from the cache.

  • getMultiple() public

    Obtains multiple cache items by their unique keys.

  • has() public

    Determines whether an item is present in the cache.

  • increment() public

    Increment a number under the key and return incremented value

  • set() public

    Persists data in the cache, uniquely referenced by the given key with an optional expiration TTL time.

  • setMultiple() public

    Persists a set of key => value pairs in the cache, with an optional TTL.

Method Detail

__construct() ¶ public

__construct(Cake\Cache\CacheEngine $innerEngine)

Constructor

Parameters
Cake\Cache\CacheEngine $innerEngine

The decorated engine.

add() ¶ public

add(string $key, mixed $value): bool

Write data for key into a cache engine if it doesn't exist already.

Parameters
string $key
mixed $value
Returns
bool

clear() ¶ public

clear(): bool

Wipes clean the entire cache's keys.

Returns
bool

clearGroup() ¶ public

clearGroup(string $group): bool

Clear all values belonging to the named group.

Each implementation needs to decide whether actually delete the keys or just augment a group generation value to achieve the same result.

Parameters
string $group
Returns
bool

decrement() ¶ public

decrement(string $key, int $offset = 1): int|false

Decrement a number under the key and return decremented value

Parameters
string $key
int $offset optional
Returns
int|false

delete() ¶ public

delete(string $key): bool

Delete an item from the cache by its unique key.

Parameters
string $key

The unique cache key of the item to delete.

Returns
bool
Throws
Cake\Cache\InvalidArgumentException
If the $key string is not a legal value.

deleteMultiple() ¶ public

deleteMultiple(iterable $keys): bool

Deletes multiple cache items in a single operation.

Parameters
iterable $keys

A list of string-based keys to be deleted.

Returns
bool
Throws
Cake\Cache\InvalidArgumentException
If $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value.

ensureValidKey() ¶ protected

ensureValidKey(string $key): void

Ensure the validity of the given cache key.

Parameters
string $key

Key to check.

Returns
void
Throws
Cake\Cache\InvalidArgumentException
When the key is not valid.

ensureValidKeys() ¶ protected

ensureValidKeys(mixed $keys): void

Ensure the validity of the given cache keys.

Parameters
mixed $keys

The keys to check.

Returns
void
Throws
Cake\Cache\InvalidArgumentException
When the keys are not valid.

get() ¶ public

get(string $key, mixed $default = null): mixed

Fetches the value for a given key from the cache.

Parameters
string $key

The unique key of this item in the cache.

mixed $default optional

Default value to return if the key does not exist.

Returns
mixed
Throws
Cake\Cache\InvalidArgumentException
If the $key string is not a legal value.

getMultiple() ¶ public

getMultiple(iterable $keys, mixed $default = null): iterable

Obtains multiple cache items by their unique keys.

Parameters
iterable $keys

A list of keys that can obtained in a single operation.

mixed $default optional

Default value to return for keys that do not exist.

Returns
iterable
Throws
Cake\Cache\InvalidArgumentException
If $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value.

has() ¶ public

has(string $key): bool

Determines whether an item is present in the cache.

NOTE: It is recommended that has() is only to be used for cache warming type purposes and not to be used within your live applications operations for get/set, as this method is subject to a race condition where your has() will return true and immediately after, another script can remove it making the state of your app out of date.

Parameters
string $key

The cache item key.

Returns
bool
Throws
Cake\Cache\InvalidArgumentException
If the $key string is not a legal value.

increment() ¶ public

increment(string $key, int $offset = 1): int|false

Increment a number under the key and return incremented value

Parameters
string $key
int $offset optional
Returns
int|false

set() ¶ public

set(string $key, mixed $value, null|int|DateInterval $ttl = null): bool

Persists data in the cache, uniquely referenced by the given key with an optional expiration TTL time.

Parameters
string $key

The key of the item to store.

mixed $value

The value of the item to store, must be serializable.

null|int|DateInterval $ttl optional

Optional. The TTL value of this item. If no value is sent and the driver supports TTL then the library may set a default value for it or let the driver take care of that.

Returns
bool
Throws
Cake\Cache\InvalidArgumentException

setMultiple() ¶ public

setMultiple(iterable $values, null|int|DateInterval $ttl = null): bool

Persists a set of key => value pairs in the cache, with an optional TTL.

Parameters
iterable $values

A list of key => value pairs for a multiple-set operation.

null|int|DateInterval $ttl optional

Optional. The TTL value of this item. If no value is sent and the driver supports TTL then the library may set a default value for it or let the driver take care of that.

Returns
bool
Throws
Cake\Cache\InvalidArgumentException
If $values is neither an array nor a Traversable, or if any of the $values are not a legal value.

Property Detail

$innerEngine ¶ protected

The wrapped cache engine object.

Type
Cake\Cache\CacheEngine
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