Cache\AbstractCache
Abstract Source on GitHubThis component offers caching capabilities for your application.
Event layering: cache operations can emit cache:* events from two layers.
This facade fires cache:before*/cache:after* around each operation, and
the underlying Storage adapter (whose eventType is "cache") also fires
cache:before*/cache:after* for the same operation. If an events manager
is wired into both the facade and the adapter, a single call emits the event
twice (once from each object). Wire the manager into one layer only; the
facade is the supported source for cache-level events (it also emits the
multi-key cache:*Multiple events).
Phalcon\Cache\AbstractCache- implementsPhalcon\Cache\CacheInterface,Phalcon\Events\EventsAwareInterface
Uses DateInterval · Phalcon\Cache\Adapter\AdapterInterface · Phalcon\Cache\Adapter\Redis · Phalcon\Events\EventsAwareInterface · Phalcon\Events\Traits\EventsAwareTrait · Redis · Throwable · Traversable
Method Summary
public__construct(AdapterInterface $adapter)Constructor.
publicmixedget(string $key,mixed $defaultValue = null)Fetches a value from the cache.
publicAdapterInterfacegetAdapter()Returns the current adapter
publicboolset(string $key,mixed $value,mixed $ttl = null)Persists data in the cache, uniquely referenced by a key with an
protectedvoidcheckKey(string $key)Checks the key. If it contains invalid characters an exception is thrown
protectedvoidcheckKeys(mixed $keys)Checks the key. If it contains invalid characters an exception is thrown
protectedbooldoClear()Wipes clean the entire cache’s keys.
protectedbooldoDelete(string $key)Delete an item from the cache by its unique key.
protectedbooldoDeleteMultiple(mixed $keys)Deletes multiple cache items in a single operation.
protectedmixeddoGet(string $key,mixed $defaultValue = null)Fetches a value from the cache.
protectedarraydoGetMultiple(mixed $keys,mixed $defaultValue = null)Obtains multiple cache items by their unique keys.
protectedbooldoHas(string $key)Determines whether an item is present in the cache.
protectedbooldoSet(string $key,mixed $value,mixed $ttl = null)Persists data in the cache, uniquely referenced by a key with an optional
protectedbooldoSetMultiple(mixed $values,mixed $ttl = null)Persists a set of key => value pairs in the cache, with an optional TTL.
protectedstringgetExceptionClass()Returns the exception class that will be used for exceptions thrown
Properties
protectedAdapterInterface$adapterMethods
__construct()
public function __construct( AdapterInterface $adapter );Constructor.
get()
abstract public function get(
string $key,
mixed $defaultValue = null
): mixed;Fetches a value from the cache.
getAdapter()
public function getAdapter(): AdapterInterface;Returns the current adapter
set()
abstract public function set(
string $key,
mixed $value,
mixed $ttl = null
): bool;Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
checkKey()
protected function checkKey( string $key ): void;Checks the key. If it contains invalid characters an exception is thrown
checkKeys()
protected function checkKeys( mixed $keys ): void;Checks the key. If it contains invalid characters an exception is thrown
doClear()
protected function doClear(): bool;Wipes clean the entire cache’s keys.
doDelete()
protected function doDelete( string $key ): bool;Delete an item from the cache by its unique key.
doDeleteMultiple()
protected function doDeleteMultiple( mixed $keys ): bool;Deletes multiple cache items in a single operation.
doGet()
protected function doGet(
string $key,
mixed $defaultValue = null
): mixed;Fetches a value from the cache.
doGetMultiple()
protected function doGetMultiple(
mixed $keys,
mixed $defaultValue = null
): array;Obtains multiple cache items by their unique keys.
doHas()
protected function doHas( string $key ): bool;Determines whether an item is present in the cache.
doSet()
protected function doSet(
string $key,
mixed $value,
mixed $ttl = null
): bool;Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
doSetMultiple()
protected function doSetMultiple(
mixed $values,
mixed $ttl = null
): bool;Persists a set of key => value pairs in the cache, with an optional TTL.
getExceptionClass()
abstract protected function getExceptionClass(): string;Returns the exception class that will be used for exceptions thrown
Cache\AdapterFactory
Class Source on GitHubFactory to create Cache adapters
Phalcon\Factory\AbstractConfigFactoryPhalcon\Factory\AbstractFactoryPhalcon\Cache\AdapterFactory
Uses Phalcon\Cache\Adapter\AdapterInterface · Phalcon\Cache\Adapter\Apcu · Phalcon\Cache\Adapter\Libmemcached · Phalcon\Cache\Adapter\Memory · Phalcon\Cache\Adapter\Redis · Phalcon\Cache\Adapter\RedisCluster · Phalcon\Cache\Adapter\Stream · Phalcon\Cache\Adapter\Weak · Phalcon\Cache\Exception\Exception · Phalcon\Contracts\Storage\StorageTypes · Phalcon\Factory\AbstractFactory · Phalcon\Storage\SerializerFactory
Method Summary
public__construct(SerializerFactory $serializerFactory,array $services = [])AdapterFactory constructor.
publicAdapterInterfacenewInstance(string $name,array $options = [])Create a new instance of the adapter
protectedstringgetExceptionClass()protectedarraygetServices()Returns the available adapters
Properties
protectedSerializerFactory$serializerFactoryMethods
__construct()
public function __construct(
SerializerFactory $serializerFactory,
array $services = []
);AdapterFactory constructor.
newInstance()
public function newInstance(
string $name,
array $options = []
): AdapterInterface;Create a new instance of the adapter
getExceptionClass()
protected function getExceptionClass(): string;getServices()
protected function getServices(): array;Returns the available adapters
Cache\Adapter\AdapterInterface
Interface Source on GitHubInterface for Phalcon\Cache adapters
Phalcon\Storage\Adapter\AdapterInterfacePhalcon\Cache\Adapter\AdapterInterface
Uses Phalcon\Storage\Adapter\AdapterInterface
Cache\Adapter\Apcu
Class Source on GitHubApcu adapter
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\ApcuPhalcon\Cache\Adapter\Apcu- implementsPhalcon\Cache\Adapter\AdapterInterface
Uses Phalcon\Cache\Adapter\AdapterInterface · Phalcon\Storage\Adapter\Apcu
Properties
protectedstring$eventType = "cache"EventType prefix.
Cache\Adapter\Libmemcached
Class Source on GitHubLibmemcached adapter
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\LibmemcachedPhalcon\Cache\Adapter\Libmemcached- implementsPhalcon\Cache\Adapter\AdapterInterface
Uses Phalcon\Cache\Adapter\AdapterInterface · Phalcon\Storage\Adapter\Libmemcached
Properties
protectedstring$eventType = "cache"EventType prefix.
Cache\Adapter\Memory
Class Source on GitHubMemory adapter
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\MemoryPhalcon\Cache\Adapter\Memory- implementsPhalcon\Cache\Adapter\AdapterInterface
Uses Phalcon\Cache\Adapter\AdapterInterface · Phalcon\Storage\Adapter\Memory
Properties
protectedstring$eventType = "cache"EventType prefix.
Cache\Adapter\Redis
Class Source on GitHubRedis adapter
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\RedisPhalcon\Cache\Adapter\Redis- implementsPhalcon\Cache\Adapter\AdapterInterface
Uses Phalcon\Cache\Adapter\AdapterInterface · Phalcon\Storage\Adapter\Redis
Properties
protectedstring$eventType = "cache"EventType prefix.
Cache\Adapter\RedisCluster
Class Source on GitHubRedisCluster adapter
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\RedisPhalcon\Storage\Adapter\RedisClusterPhalcon\Cache\Adapter\RedisCluster- implementsPhalcon\Cache\Adapter\AdapterInterface
Uses Phalcon\Cache\Adapter\AdapterInterface · Phalcon\Storage\Adapter\RedisCluster
Properties
protectedstring$eventType = "cache"EventType prefix.
Cache\Adapter\Stream
Class Source on GitHubStream adapter
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\StreamPhalcon\Cache\Adapter\Stream- implementsPhalcon\Cache\Adapter\AdapterInterface
Uses Phalcon\Cache\Adapter\AdapterInterface · Phalcon\Storage\Adapter\Stream
Properties
protectedstring$eventType = "cache"EventType prefix.
Cache\Adapter\Weak
Class Source on GitHubWeakCache implementation based on WeakReference
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\WeakPhalcon\Cache\Adapter\Weak- implementsPhalcon\Cache\Adapter\AdapterInterface
Uses Phalcon\Cache\Adapter\AdapterInterface · Phalcon\Storage\Adapter\Weak
Properties
protectedstring$eventType = "cache"EventType prefix.
Cache\Cache
Class Source on GitHubThis component offers caching capabilities for your application.
Phalcon\Cache\AbstractCachePhalcon\Cache\Cache
Uses DateInterval · Phalcon\Cache\Exception\InvalidArgumentException · Throwable
Method Summary
publicboolclear()Wipes clean the entire cache’s keys.
publicbooldelete(string $key)Delete an item from the cache by its unique key.
publicbooldeleteMultiple(mixed $keys)Deletes multiple cache items in a single operation.
publicmixedget(string $key,mixed $defaultValue = null)Fetches a value from the cache.
publicmixedgetMultiple(mixed $keys,mixed $defaultValue = null)Obtains multiple cache items by their unique keys.
publicboolhas(string $key)Determines whether an item is present in the cache.
publicboolset(string $key,mixed $value,mixed $ttl = null)Persists data in the cache, uniquely referenced by a key with an optional
publicboolsetMultiple(mixed $values,mixed $ttl = null)Persists a set of key => value pairs in the cache, with an optional TTL.
protectedstringgetExceptionClass()Returns the exception class that will be used for exceptions thrown
Methods
clear()
public function clear(): bool;Wipes clean the entire cache’s keys.
delete()
public function delete( string $key ): bool;Delete an item from the cache by its unique key.
deleteMultiple()
public function deleteMultiple( mixed $keys ): bool;Deletes multiple cache items in a single operation.
get()
public function get(
string $key,
mixed $defaultValue = null
): mixed;Fetches a value from the cache.
getMultiple()
public function getMultiple(
mixed $keys,
mixed $defaultValue = null
): mixed;Obtains multiple cache items by their unique keys.
has()
public function has( string $key ): bool;Determines whether an item is present in the cache.
set()
public function set(
string $key,
mixed $value,
mixed $ttl = null
): bool;Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
setMultiple()
public function setMultiple(
mixed $values,
mixed $ttl = null
): bool;Persists a set of key => value pairs in the cache, with an optional TTL.
getExceptionClass()
protected function getExceptionClass(): string;Returns the exception class that will be used for exceptions thrown
Cache\CacheFactory
Class Source on GitHubCreates a new Cache class
Phalcon\Factory\AbstractConfigFactoryPhalcon\Cache\CacheFactory
Uses Phalcon\Cache\Exception\Exception · Phalcon\Config\ConfigInterface · Phalcon\Contracts\Storage\StorageTypes · Phalcon\Factory\AbstractConfigFactory
Method Summary
public__construct(AdapterFactory $adapterFactory)Constructor
publicCacheInterfaceload(mixed $config)Factory to create an instance from a Config object
publicCacheInterfacenewInstance(string $name,array $options = [])Constructs a new Cache instance.
protectedstringgetExceptionClass()Returns the exception class for the factory
Properties
protectedAdapterFactory$adapterFactoryMethods
__construct()
public function __construct( AdapterFactory $adapterFactory );Constructor
load()
public function load( mixed $config ): CacheInterface;Factory to create an instance from a Config object
newInstance()
public function newInstance(
string $name,
array $options = []
): CacheInterface;Constructs a new Cache instance.
getExceptionClass()
protected function getExceptionClass(): string;Returns the exception class for the factory
Cache\CacheInterface
Interface Source on GitHubInterface for Phalcon\Cache\Cache
The cache class carries this member and the framework calls it on the interface. It joins the contract in the next major; until then the tag below records what all implementations provide.
@method AdapterInterface getAdapter()
Phalcon\Contracts\Cache\CachePhalcon\Cache\CacheInterface
Uses Phalcon\Cache\Adapter\AdapterInterface · Phalcon\Contracts\Cache\Cache
Cache\Exception\Exception
Class Source on GitHubExceptions thrown in Phalcon\Cache will use this class
\ExceptionPhalcon\Cache\Exception\Exception
Cache\Exception\InvalidArgumentException
Class Source on GitHubExceptions thrown in Phalcon\Cache for invalid arguments will use this class
\ExceptionPhalcon\Cache\Exception\InvalidArgumentException