Phalcon cache
NOTE
All classes are prefixed with Phalcon
Cache\AbstractCache¶
Abstract Source on GitHub
This 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\Cache\Exception\InvalidArgumentException · Phalcon\Events\EventsAwareInterface · Phalcon\Events\ManagerInterface · Traversable
Method Summary¶
public
__construct( AdapterInterface $adapter )
Constructor.
public
get(string $key,mixed $defaultValue = null)
Fetches a value from the cache.
public
AdapterInterface
getAdapter()
Returns the current adapter
public
ManagerInterface|null
getEventsManager()
Get the event manager
public
bool
set(string $key,mixed $value,mixed $ttl = null)
Persists data in the cache, uniquely referenced by a key with an
public
void
setEventsManager( ManagerInterface $eventsManager )
Sets the event manager
protected
void
checkKey( string $key )
Checks the key. If it contains invalid characters an exception is thrown
protected
void
checkKeys( mixed $keys )
Checks the key. If it contains invalid characters an exception is thrown
protected
bool
doClear()
Wipes clean the entire cache's keys.
protected
bool
doDelete( string $key )
Delete an item from the cache by its unique key.
protected
bool
doDeleteMultiple( mixed $keys )
Deletes multiple cache items in a single operation.
protected
mixed
doGet(string $key,mixed $defaultValue = null)
Fetches a value from the cache.
protected
array
doGetMultiple(mixed $keys,mixed $defaultValue = null)
Obtains multiple cache items by their unique keys.
protected
bool
doHas( string $key )
Determines whether an item is present in the cache.
protected
bool
doSet(string $key,mixed $value,mixed $ttl = null)
Persists data in the cache, uniquely referenced by a key with an optional
protected
bool
doSetMultiple(mixed $values,mixed $ttl = null)
Persists a set of key => value pairs in the cache, with an optional TTL.
protected
void
fire(string $eventName,mixed $keys)
Trigger an event for the eventsManager.
protected
string
getExceptionClass()
Returns the exception class that will be used for exceptions thrown
Properties¶
protected
AdapterInterface
$adapter
The adapter
protected
ManagerInterface|null
$eventsManager = null
Event Manager
Methods¶
__construct()¶
Constructor.
get()¶
Fetches a value from the cache.
getAdapter()¶
Returns the current adapter
getEventsManager()¶
Get the event manager
set()¶
Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
setEventsManager()¶
Sets the event manager
checkKey()¶
Checks the key. If it contains invalid characters an exception is thrown
checkKeys()¶
Checks the key. If it contains invalid characters an exception is thrown
doClear()¶
Wipes clean the entire cache's keys.
doDelete()¶
Delete an item from the cache by its unique key.
doDeleteMultiple()¶
Deletes multiple cache items in a single operation.
doGet()¶
Fetches a value from the cache.
doGetMultiple()¶
Obtains multiple cache items by their unique keys.
doHas()¶
Determines whether an item is present in the cache.
doSet()¶
Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
doSetMultiple()¶
Persists a set of key => value pairs in the cache, with an optional TTL.
fire()¶
Trigger an event for the eventsManager.
getExceptionClass()¶
Returns the exception class that will be used for exceptions thrown
Cache\AdapterFactory¶
Class Source on GitHub
Factory to create Cache adapters
Phalcon\Factory\AbstractConfigFactoryPhalcon\Factory\AbstractFactoryPhalcon\Cache\AdapterFactory
Uses Phalcon\Cache\Adapter\AdapterInterface · Phalcon\Cache\Exception\Exception · Phalcon\Factory\AbstractFactory · Phalcon\Storage\SerializerFactory
Method Summary¶
public
__construct(SerializerFactory $factory,array $services = [])
AdapterFactory constructor.
public
AdapterInterface
newInstance(string $name,array $options = [])
Create a new instance of the adapter
protected
string
getExceptionClass()
protected
array
getServices()
Returns the available adapters
Properties¶
protected
SerializerFactory
$serializerFactory
Methods¶
__construct()¶
AdapterFactory constructor.
newInstance()¶
Create a new instance of the adapter
getExceptionClass()¶
getServices()¶
Returns the available adapters
Cache\Adapter\AdapterInterface¶
Interface Source on GitHub
Interface for Phalcon\Cache adapters
Phalcon\Storage\Adapter\AdapterInterfacePhalcon\Cache\Adapter\AdapterInterface
Uses Phalcon\Storage\Adapter\AdapterInterface
Cache\Adapter\Apcu¶
Class Source on GitHub
Apcu 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¶
protected
string
$eventType = "cache"
Cache\Adapter\Libmemcached¶
Class Source on GitHub
Libmemcached 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¶
protected
string
$eventType = "cache"
Cache\Adapter\Memory¶
Class Source on GitHub
Memory 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¶
protected
string
$eventType = "cache"
Cache\Adapter\Redis¶
Class Source on GitHub
Redis 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¶
protected
string
$eventType = "cache"
Cache\Adapter\RedisCluster¶
Class Source on GitHub
RedisCluster 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¶
protected
string
$eventType = "cache"
Cache\Adapter\Stream¶
Class Source on GitHub
Stream 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¶
protected
string
$eventType = "cache"
Cache\Adapter\Weak¶
Class Source on GitHub
WeakCache 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¶
protected
string
$eventType = "cache"
Cache\Cache¶
Class Source on GitHub
This component offers caching capabilities for your application.
Phalcon\Cache\AbstractCachePhalcon\Cache\Cache
Uses DateInterval · Phalcon\Cache\Adapter\AdapterInterface · Phalcon\Cache\Exception\InvalidArgumentException
Method Summary¶
public
bool
clear()
Wipes clean the entire cache's keys.
public
bool
delete( string $key )
Delete an item from the cache by its unique key.
public
bool
deleteMultiple( mixed $keys )
Deletes multiple cache items in a single operation.
public
get(string $key,mixed $defaultValue = null)
Fetches a value from the cache.
public
getMultiple(mixed $keys,mixed $defaultValue = null)
Obtains multiple cache items by their unique keys.
public
bool
has( string $key )
Determines whether an item is present in the cache.
public
bool
set(string $key,mixed $value,mixed $ttl = null)
Persists data in the cache, uniquely referenced by a key with an optional
public
bool
setMultiple(mixed $values,mixed $ttl = null)
Persists a set of key => value pairs in the cache, with an optional TTL.
protected
string
getExceptionClass()
Returns the exception class that will be used for exceptions thrown
Methods¶
clear()¶
Wipes clean the entire cache's keys.
delete()¶
Delete an item from the cache by its unique key.
deleteMultiple()¶
Deletes multiple cache items in a single operation.
get()¶
Fetches a value from the cache.
getMultiple()¶
Obtains multiple cache items by their unique keys.
has()¶
Determines whether an item is present in the cache.
set()¶
Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
setMultiple()¶
Persists a set of key => value pairs in the cache, with an optional TTL.
getExceptionClass()¶
Returns the exception class that will be used for exceptions thrown
Cache\CacheFactory¶
Class Source on GitHub
Creates a new Cache class
Phalcon\Factory\AbstractConfigFactoryPhalcon\Cache\CacheFactory
Uses Phalcon\Cache\Adapter\AdapterInterface · Phalcon\Cache\Cache · Phalcon\Cache\Exception\Exception · Phalcon\Config\ConfigInterface · Phalcon\Factory\AbstractConfigFactory
Method Summary¶
public
__construct( AdapterFactory $factory )
Constructor
public
CacheInterface
load( mixed $config )
Factory to create an instance from a Config object
public
CacheInterface
newInstance(string $name,array $options = [])
Constructs a new Cache instance.
protected
string
getExceptionClass()
Properties¶
protected
AdapterFactory
$adapterFactory
Methods¶
__construct()¶
Constructor
load()¶
Factory to create an instance from a Config object
newInstance()¶
Constructs a new Cache instance.
getExceptionClass()¶
Cache\CacheInterface¶
Interface Source on GitHub
Interface for Phalcon\Cache\Cache
Phalcon\Contracts\Cache\CachePhalcon\Cache\CacheInterface
Uses Phalcon\Contracts\Cache\Cache
Cache\Exception\Exception¶
Class Source on GitHub
Exceptions thrown in Phalcon\Cache will use this class
\ExceptionPhalcon\Cache\Exception\Exception
Cache\Exception\InvalidArgumentException¶
Class Source on GitHub
Exceptions thrown in Phalcon\Cache will use this class
\ExceptionPhalcon\Cache\Exception\InvalidArgumentException