Phalcon storage
NOTE
All classes are prefixed with Phalcon
Storage\AdapterFactory¶
Class Source on GitHub
Class AdapterFactory
@property SerializerFactory $serializerFactory
Phalcon\Storage\AdapterFactory
Uses Exception · Phalcon\Storage\Adapter\AdapterInterface · Phalcon\Storage\Adapter\Apcu · Phalcon\Storage\Adapter\Libmemcached · Phalcon\Storage\Adapter\Memory · Phalcon\Storage\Adapter\Redis · Phalcon\Storage\Adapter\RedisCluster · Phalcon\Storage\Adapter\Stream · Phalcon\Storage\Adapter\Weak · Phalcon\Traits\Factory\FactoryTrait
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
Methods¶
__construct()¶
AdapterFactory constructor.
newInstance()¶
Create a new instance of the adapter
getExceptionClass()¶
getServices()¶
Returns the available adapters
Storage\Adapter\AbstractAdapter¶
Abstract Source on GitHub
Class AbstractAdapter
@package Phalcon\Storage\Adapter
@property mixed $adapter @property string $defaultSerializer @property int $lifetime @property array $options @property string $prefix @property SerializerInterface $serializer @property SerializerFactory $serializerFactory
Phalcon\Storage\Adapter\AbstractAdapter- implementsPhalcon\Storage\Adapter\AdapterInterface,Phalcon\Events\EventsAwareInterface
Uses DateInterval · DateTime · Exception · Phalcon\Events\EventsAwareInterface · Phalcon\Events\Traits\EventsAwareTrait · Phalcon\Storage\SerializerFactory · Phalcon\Storage\Serializer\SerializerInterface · Phalcon\Traits\Support\Helper\Arr\GetTrait
Method Summary¶
public
bool
clear()
Flushes/clears the cache
public
false|int
decrement(string $key,int $value = 1)
Decrements a stored number
public
bool
delete( string $key )
Deletes data from the adapter
public
bool
deleteMultiple( array $keys )
Deletes multiple data from the adapter
public
mixed
get(string $key,mixed $defaultValue = null)
Reads data from the adapter
public
mixed
getAdapter()
Returns the adapter - connects to the storage if not connected
public
string
getDefaultSerializer()
Name of the default serializer class
public
array
getKeys( string $prefix = "" )
Returns all the keys stored
public
int
getLifetime()
Returns the lifetime
public
string
getPrefix()
Returns the prefix
public
SerializerInterface|null
getSerializer()
Get the serializer
public
bool
has( string $key )
Checks if an element exists in the cache
public
false|int
increment(string $key,int $value = 1)
Increments a stored number
public
bool
set(string $key,mixed $value,mixed $ttl = null)
Stores data in the adapter. If the TTL is null (default) or not defined
public
void
setDefaultSerializer( string $serializer )
protected
__construct(SerializerFactory $serializerFactory,array $options = [])
AbstractAdapter constructor.
protected
false|int
doDecrement(string $key,int $value = 1)
Decrements a stored number
protected
bool
doDelete( string $key )
Deletes data from the adapter
protected
bool
doDeleteMultiple( array $keys )
Deletes multiple data from the adapter
protected
mixed
doGet(string $key,mixed $defaultValue = null)
protected
mixed
doGetData( string $key )
protected
bool
doHas( string $key )
Checks if an element exists in the cache
protected
false|int
doIncrement(string $key,int $value = 1)
Increments a stored number
protected
bool
doSet(string $key,mixed $value,mixed $ttl = null)
Stores data in the adapter. If the TTL is null (default) or not defined
protected
array
getFilteredKeys(mixed $keys,string $prefix)
Filters the keys array based on global and passed prefix
protected
string
getKeyWithoutPrefix( string $key )
Check if the key has the prefix and remove it, otherwise just return the
protected
string
getPrefixedKey( mixed $key )
Returns the key requested, prefixed
protected
mixed
getSerializedData( mixed $content )
Returns serialized data
protected
int
getTtl( mixed $ttl )
Calculates the TTL for a cache item
protected
mixed
getUnserializedData(mixed $content,mixed $defaultValue = null)
Returns unserialized data
protected
void
initSerializer()
Initializes the serializer
Properties¶
protected
mixed
$adapter
protected
string
$defaultSerializer = "php"
Name of the default serializer class
protected
string
$eventType = "storage"
EventType prefix.
protected
int
$lifetime = 3600
Name of the default TTL (time to live)
protected
array
$options = []
protected
string
$prefix = "ph-memo-"
protected
SerializerInterface|null
$serializer
Serializer
protected
SerializerFactory
$serializerFactory
protected
bool
$stripPrefix = true
Whether a leading prefix is stripped from incoming keys before the
adapter prefix is applied. Disable when keys are externally
generated identifiers that may legitimately start with the prefix
text (e.g. session ids).
Methods¶
clear()¶
Flushes/clears the cache
decrement()¶
Decrements a stored number
delete()¶
Deletes data from the adapter
deleteMultiple()¶
Deletes multiple data from the adapter
get()¶
Reads data from the adapter
getAdapter()¶
Returns the adapter - connects to the storage if not connected
getDefaultSerializer()¶
Name of the default serializer class
getKeys()¶
Returns all the keys stored
getLifetime()¶
Returns the lifetime
getPrefix()¶
Returns the prefix
getSerializer()¶
Get the serializer
has()¶
Checks if an element exists in the cache
increment()¶
Increments a stored number
set()¶
Stores data in the adapter. If the TTL is null (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is 0 or a negative number, a delete() will be issued, since this
item has expired. If you need to set this key forever, you should use
the setForever() method.
setDefaultSerializer()¶
__construct()¶
AbstractAdapter constructor.
doDecrement()¶
Decrements a stored number
doDelete()¶
Deletes data from the adapter
doDeleteMultiple()¶
Deletes multiple data from the adapter
doGet()¶
doGetData()¶
doHas()¶
Checks if an element exists in the cache
doIncrement()¶
Increments a stored number
doSet()¶
Stores data in the adapter. If the TTL is null (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is 0 or a negative number, a delete() will be issued, since this
item has expired. If you need to set this key forever, you should use
the setForever() method.
getFilteredKeys()¶
Filters the keys array based on global and passed prefix
getKeyWithoutPrefix()¶
Check if the key has the prefix and remove it, otherwise just return the
key unaltered. When the stripPrefix option is false the key is
always returned unaltered.
getPrefixedKey()¶
Returns the key requested, prefixed
getSerializedData()¶
Returns serialized data
getTtl()¶
Calculates the TTL for a cache item
getUnserializedData()¶
Returns unserialized data
initSerializer()¶
Initializes the serializer
Storage\Adapter\AdapterInterface¶
Interface Source on GitHub
Interface for Phalcon\Logger adapters
Phalcon\Storage\Adapter\AdapterInterface
Uses DateInterval
Method Summary¶
public
bool
clear()
Flushes/clears the cache
public
false|int
decrement(string $key,int $value = 1)
Decrements a stored number
public
bool
delete( string $key )
Deletes data from the adapter
public
bool
deleteMultiple( array $keys )
Deletes multiple data from the adapter
public
mixed
get(string $key,mixed $defaultValue = null)
Reads data from the adapter
public
mixed
getAdapter()
Returns the adapter - connects to the storage if not connected
public
array
getKeys( string $prefix = "" )
Returns all the keys stored
public
string
getPrefix()
Returns the prefix for the keys
public
bool
has( string $key )
Checks if an element exists in the cache
public
false|int
increment(string $key,int $value = 1)
Increments a stored number
public
bool
set(string $key,mixed $value,mixed $ttl = null)
Stores data in the adapter. If the TTL is null (default) or not defined
public
bool
setForever(string $key,mixed $data)
Stores data in the adapter forever. The key needs to be manually deleted
Methods¶
clear()¶
Flushes/clears the cache
decrement()¶
Decrements a stored number
delete()¶
Deletes data from the adapter
deleteMultiple()¶
Deletes multiple data from the adapter
get()¶
Reads data from the adapter
getAdapter()¶
Returns the adapter - connects to the storage if not connected
getKeys()¶
Returns all the keys stored
getPrefix()¶
Returns the prefix for the keys
has()¶
Checks if an element exists in the cache
increment()¶
Increments a stored number
set()¶
Stores data in the adapter. If the TTL is null (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is 0 or a negative number, a delete() will be issued, since this
item has expired. If you need to set this key forever, you should use
the setForever() method.
setForever()¶
Stores data in the adapter forever. The key needs to be manually deleted from the adapter.
Storage\Adapter\Apcu¶
Class Source on GitHub
Apcu adapter
Capabilities: - Counters: native atomic (apcu_inc()/apcu_dec()). - getKeys(): APCUIterator regex scan over the shared APCu store. - Serializers: Phalcon-side only; no backend-native serializer.
@property array $options
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\Apcu
Uses APCUIterator · DateInterval · Exception · Phalcon\Storage\SerializerFactory · Phalcon\Traits\Php\ApcuTrait
Method Summary¶
public
__construct(SerializerFactory $factory,array $options = [])
Apcu constructor.
public
bool
clear()
Flushes/clears the cache
public
array
getKeys( string $prefix = "" )
Stores data in the adapter
public
bool
setForever(string $key,mixed $data)
Stores data in the adapter forever. The key needs to manually deleted
protected
false|int
doDecrement(string $key,int $value = 1)
Decrements a stored number
protected
bool
doDelete( string $key )
Reads data from the adapter
protected
bool
doDeleteMultiple( array $keys )
Deletes multiple keys from APCu in a single call
protected
mixed
doGetData( string $key )
protected
bool
doHas( string $key )
Checks if an element exists in the cache
protected
false|int
doIncrement(string $key,int $value = 1)
Increments a stored number
protected
bool
doSet(string $key,mixed $value,mixed $ttl = null)
Stores data in the adapter. If the TTL is null (default) or not defined
Properties¶
protected
string
$prefix = "ph-apcu-"
Methods¶
__construct()¶
Apcu constructor.
clear()¶
Flushes/clears the cache
getKeys()¶
Stores data in the adapter
setForever()¶
Stores data in the adapter forever. The key needs to manually deleted from the adapter.
doDecrement()¶
Decrements a stored number
doDelete()¶
Reads data from the adapter
doDeleteMultiple()¶
Deletes multiple keys from APCu in a single call
doGetData()¶
doHas()¶
Checks if an element exists in the cache
doIncrement()¶
Increments a stored number
doSet()¶
Stores data in the adapter. If the TTL is null (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is 0 or a negative number, a delete() will be issued, since this
item has expired. If you need to set this key forever, you should use
the setForever() method.
Storage\Adapter\Libmemcached¶
Class Source on GitHub
Libmemcached adapter
Capabilities: - Counters: native atomic (Memcached::increment()/decrement()). - getKeys(): Memcached::getAllKeys(), which is server-dependent and may be incomplete or unavailable on modern memcached builds. - Serializers: Phalcon-side plus libmemcached's own options.
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\Libmemcached
Uses DateInterval · Exception · Memcached · Phalcon\Storage\Exception · Phalcon\Storage\Exceptions\ConnectionFailed · Phalcon\Storage\Exceptions\InvalidConfiguration · Phalcon\Storage\SerializerFactory · Phalcon\Support\Exception
Method Summary¶
public
__construct(SerializerFactory $factory,array $options = [])
Libmemcached constructor.
public
bool
clear()
Flushes/clears the cache
public
mixed
getAdapter()
Returns the already connected adapter or connects to the Memcached
public
array
getKeys( string $prefix = "" )
Stores data in the adapter
public
bool
setForever(string $key,mixed $data)
Stores data in the adapter forever. The key needs to be manually deleted
protected
false|int
doDecrement(string $key,int $value = 1)
Decrements a stored number
protected
bool
doDelete( string $key )
Reads data from the adapter
protected
bool
doDeleteMultiple( array $keys )
Deletes multiple keys from Memcached using a single deleteMulti call
protected
bool
doHas( string $key )
Checks if an element exists in the cache
protected
false|int
doIncrement(string $key,int $value = 1)
Increments a stored number
protected
bool
doSet(string $key,mixed $value,mixed $ttl = null)
Stores data in the adapter. If the TTL is null (default) or not defined
Properties¶
protected
string
$prefix = "ph-memc-"
Methods¶
__construct()¶
Libmemcached constructor.
clear()¶
Flushes/clears the cache
getAdapter()¶
Returns the already connected adapter or connects to the Memcached server(s)
getKeys()¶
Stores data in the adapter
setForever()¶
Stores data in the adapter forever. The key needs to be manually deleted from the adapter.
doDecrement()¶
Decrements a stored number
doDelete()¶
Reads data from the adapter
doDeleteMultiple()¶
Deletes multiple keys from Memcached using a single deleteMulti call
doHas()¶
Checks if an element exists in the cache
doIncrement()¶
Increments a stored number
doSet()¶
Stores data in the adapter. If the TTL is null (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is 0 or a negative number, a delete() will be issued, since this
item has expired. If you need to set this key forever, you should use
the setForever() method.
Storage\Adapter\Memory¶
Class Source on GitHub
Memory adapter
@property array $data @property array $options
Capabilities: - Scope: per-request, in-process; nothing is shared across requests or processes and the store is discarded when the request ends. - Counters: read-modify-write on the in-memory array. - getKeys(): in-memory array scan (cheap). - Optional maxItems FIFO cap drops the oldest entry before a new key is set.
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\Memory
Uses DateInterval · Exception · Phalcon\Storage\SerializerFactory
Method Summary¶
public
__construct(SerializerFactory $factory,array $options = [])
Memory constructor.
public
bool
clear()
Flushes/clears the cache
public
array
getKeys( string $prefix = "" )
Stores data in the adapter
public
int
getMaxItems()
Returns the configured store cap (0 = unlimited). See setMaxItems().
public
bool
setForever(string $key,mixed $data)
Stores data in the adapter forever. The key needs to manually deleted
public
static
setMaxItems( int $maxItems )
Caps the number of items retained in the in-memory store.
protected
false|int
doDecrement(string $key,int $value = 1)
Decrements a stored number
protected
bool
doDelete( string $key )
Deletes data from the adapter
protected
mixed
doGetData( string $key )
protected
bool
doHas( string $key )
Checks if an element exists in the cache
protected
false|int
doIncrement(string $key,int $value = 1)
Increments a stored number
protected
bool
doSet(string $key,mixed $value,mixed $ttl = null)
Stores data in the adapter. If the TTL is null (default) or not defined
Properties¶
protected
array
$data = []
protected
int
$maxItems = 0
Maximum number of items retained in the in-memory store.
0 (default) keeps the original unbounded behavior; a positive
value drops the oldest entry FIFO before a new key is stored.
Methods¶
__construct()¶
Memory constructor.
clear()¶
Flushes/clears the cache
getKeys()¶
Stores data in the adapter
getMaxItems()¶
Returns the configured store cap (0 = unlimited). See setMaxItems().
setForever()¶
Stores data in the adapter forever. The key needs to manually deleted from the adapter.
setMaxItems()¶
Caps the number of items retained in the in-memory store. 0 disables the cap (the default; preserves the original unbounded behavior). When the cap is exceeded, the oldest entry is evicted FIFO before a new key is stored.
doDecrement()¶
Decrements a stored number
doDelete()¶
Deletes data from the adapter
doGetData()¶
doHas()¶
Checks if an element exists in the cache
doIncrement()¶
Increments a stored number
doSet()¶
Stores data in the adapter. If the TTL is null (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is 0 or a negative number, a delete() will be issued, since this
item has expired. If you need to set this key forever, you should use
the setForever() method.
Storage\Adapter\Redis¶
Class Source on GitHub
Redis adapter
Capabilities: - Counters: native atomic (incrBy()/decrBy()). - getKeys(): non-blocking SCAN iteration. - Serializers: Phalcon-side, or backend-native via OPT_SERIALIZER. Native serializers change the bytes at rest and are not interchangeable with Phalcon-side serializers.
Uses DateInterval · Exception · Phalcon\Storage\Exception · Phalcon\Storage\Exceptions\AuthenticationFailed · Phalcon\Storage\Exceptions\ConnectionFailed · Phalcon\Storage\Exceptions\DatabaseSelectionFailed · Phalcon\Storage\SerializerFactory · Redis · RedisException
Method Summary¶
public
__construct(SerializerFactory $factory,array $options = [])
Redis constructor.
public
bool
clear()
Flushes/clears the cache
public
mixed
getAdapter()
Returns the already connected adapter or connects to the Redis
public
array
getKeys( string $prefix = "" )
Returns all the keys stored
public
bool
setForever(string $key,mixed $data)
Stores data in the adapter forever. The key needs to manually deleted
protected
false|int
doDecrement(string $key,int $value = 1)
Decrements a stored number
protected
bool
doDelete( string $key )
Reads data from the adapter
protected
bool
doDeleteMultiple( array $keys )
Deletes multiple keys from Redis using a single unlink call
protected
bool
doHas( string $key )
Checks if an element exists in the cache
protected
false|int
doIncrement(string $key,int $value = 1)
Increments a stored number
protected
bool
doSet(string $key,mixed $value,mixed $ttl = null)
Stores data in the adapter. If the TTL is null (default) or not defined
protected
array
getDefaultOptions( array $options )
Properties¶
protected
string
$prefix = "ph-reds-"
Methods¶
__construct()¶
Redis constructor.
clear()¶
Flushes/clears the cache
getAdapter()¶
Returns the already connected adapter or connects to the Redis server(s)
getKeys()¶
Returns all the keys stored
SCAN replaces the blocking KEYS command. SCAN_NOPREFIX keeps the prefix handling explicit: the physical prefix is matched and returned unchanged, so getFilteredKeys() sees exactly what KEYS produced.
setForever()¶
Stores data in the adapter forever. The key needs to manually deleted from the adapter.
doDecrement()¶
Decrements a stored number
doDelete()¶
Reads data from the adapter
doDeleteMultiple()¶
Deletes multiple keys from Redis using a single unlink call
doHas()¶
Checks if an element exists in the cache
doIncrement()¶
Increments a stored number
doSet()¶
Stores data in the adapter. If the TTL is null (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is 0 or a negative number, a delete() will be issued, since this
item has expired. If you need to set this key forever, you should use
the setForever() method.
getDefaultOptions()¶
Storage\Adapter\RedisCluster¶
Class Source on GitHub
RedisCluster adapter
Capabilities (in addition to Redis): - Counters: native atomic (incrBy()/decrBy()). - getKeys(): blocking KEYS across all master nodes (per-node SCAN is left to the redesign); clear() flushes every master. - Serializers: Phalcon-side, or backend-native via OPT_SERIALIZER.
@property array $options
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\RedisPhalcon\Storage\Adapter\RedisCluster
Uses Phalcon\Storage\Exceptions\ClusterConnectionFailed · Phalcon\Storage\SerializerFactory · Phalcon\Support\Exception · Redis · RedisCluster · Throwable
Method Summary¶
public
__construct(SerializerFactory $factory,array $options = [])
You can create and connect to a cluster either by passing it one or more 'seed' nodes, or by defining
public
bool
clear()
Flushes/clears the cache
public
mixed
getAdapter()
Returns the already connected adapter or connects to the Redis
public
array
getKeys( string $prefix = "" )
Returns all the keys stored
protected
array
getDefaultOptions( mixed $options )
Properties¶
protected
string
$prefix = "ph-redc-"
Methods¶
__construct()¶
You can create and connect to a cluster either by passing it one or more 'seed' nodes, or by defining these in redis.ini as a 'named' cluster.
If you are connecting with the cluster by offering a name, that is configured in redis.ini:
```
# In redis.ini
redis.clusters.seeds = "mycluster[]=localhost:7000&test[]=localhost:7001"
redis.clusters.timeout = "mycluster=5"
redis.clusters.read_timeout = "mycluster=10"
redis.clusters.auth = "mycluster=password"
```
you can use $options = ["name" => "mycluster"].
If you don't have cluster seeds configured in your redis.ini,
you should pass hosts as an array, eg. $options = ["hosts" => ["a-host:7000", "b-host:7001"]].
You can provide authentication data offering a string user=password or
array ["user" => "name", "password" => "secret"].
The timeout is the amount of time library will wait when connecting or writing to the cluster
readTimeout is the amount of time library will wait for a result from the cluster.
The context is an array of values used for ssl/tls stream context
options eg ["verify_peer" => 0, "local_cert" => "file:///path/to/cert.pem"]
clear()¶
Flushes/clears the cache
getAdapter()¶
Returns the already connected adapter or connects to the Redis server(s)
getKeys()¶
Returns all the keys stored
RedisCluster::scan() iterates one node at a time, so the blocking KEYS command is retained here (phpredis routes it across the masters). The per-node SCAN migration is left to the storage redesign.
getDefaultOptions()¶
Storage\Adapter\Stream¶
Class Source on GitHub
Stream adapter
Capabilities: - Counters: read-modify-write (doHas()/doGet()/doSet()); not atomic and racy across concurrent processes. - getKeys(): recursive directory traversal; cost grows with the entry count. - Serializers: Phalcon-side only.
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\Stream
Uses DateInterval · Exception · FilesystemIterator · Iterator · Phalcon\Storage\Exceptions\InvalidConfiguration · Phalcon\Storage\SerializerFactory · Phalcon\Traits\Php\FileTrait · Phalcon\Traits\Support\Helper\Str\DirFromFileTrait · Phalcon\Traits\Support\Helper\Str\DirSeparatorTrait · RecursiveDirectoryIterator · RecursiveIteratorIterator
Method Summary¶
public
__construct(SerializerFactory $factory,array $options = [])
Stream constructor.
public
bool
clear()
Flushes/clears the cache
public
array
getKeys( string $prefix = "" )
Stores data in the adapter
public
bool
setForever(string $key,mixed $data)
Stores data in the adapter forever. The key needs to manually deleted
protected
false|int
doDecrement(string $key,int $value = 1)
Decrements a stored number
protected
bool
doDelete( string $key )
Reads data from the adapter
protected
mixed
doGet(string $key,mixed $defaultValue = null)
Reads data from the adapter
protected
bool
doHas( string $key )
Checks if an element exists in the cache and is not expired
protected
false|int
doIncrement(string $key,int $value = 1)
Increments a stored number
protected
bool
doSet(string $key,mixed $value,mixed $ttl = null)
Stores data in the adapter. If the TTL is null (default) or not defined
Properties¶
protected
string
$prefix = "ph-strm"
protected
string
$storageDir = ""
Methods¶
__construct()¶
Stream constructor.
clear()¶
Flushes/clears the cache
getKeys()¶
Stores data in the adapter
setForever()¶
Stores data in the adapter forever. The key needs to manually deleted from the adapter.
doDecrement()¶
Decrements a stored number
doDelete()¶
Reads data from the adapter
doGet()¶
Reads data from the adapter
doHas()¶
Checks if an element exists in the cache and is not expired
doIncrement()¶
Increments a stored number
doSet()¶
Stores data in the adapter. If the TTL is null (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is 0 or a negative number, a delete() will be issued, since this
item has expired. If you need to set this key forever, you should use
the setForever() method.
Storage\Adapter\Traits\ActionTrait¶
Trait Source on GitHub
Trait for the do* methods
@method bool has(string $key) @method AdapterInterface getAdapter()
@property string $defaultSerializer @property int $lifetime @property string $prefix @property SerializerInterface|null $serializer; @property SerializerFactory $serializerFactory
Phalcon\Storage\Adapter\Traits\ActionTrait
Uses DateInterval · DateTime · Exception · Phalcon\Storage\Adapter\AdapterInterface · Phalcon\Storage\Exception · Phalcon\Storage\SerializerFactory · Phalcon\Storage\Serializer\SerializerInterface
Method Summary¶
public
bool
doDeleteMultiple( iterable $keys )
Delete multiple keys.
public
array
doGetMultiple(iterable $keys,mixed $defaultValue = null)
Get multiple keys. Returns an array success, false on failure. Raises
public
bool
doSetMultiple(iterable $values,DateInterval|int|null $ttl = null)
Sets multiple keys. Returns true on success, false on failure.
protected
false|int
doDecrement(string $key,int $value = 1)
Decrements a stored number
protected
bool
doDelete( string $key )
Deletes data from the adapter. This just checks the key and is called
protected
mixed
doGet(string $key,mixed $defaultValue = null)
protected
mixed
doGetData( string $key )
protected
bool
doHas( string $key )
Checks if an element exists in the cache
protected
false|int
doIncrement(string $key,int $value = 1)
Increments a stored number
protected
bool
doSet(string $key,mixed $value,DateInterval|int|null $ttl = null)
Stores data in the adapter. If the TTL is null (default) or not defined
protected
array
getFilteredKeys(array $keys,string $prefix)
Filters the keys array based on global and passed prefix
protected
string
getPrefixedKey( mixed $key )
Returns the key requested, prefixed
protected
mixed
getSerializedData( mixed $content )
Returns serialized data
protected
int
getTtl( mixed $ttl )
Calculates the TTL for a cache item
protected
mixed
getUnserializedData(mixed $content,mixed $defaultValue = null)
Returns unserialized data
protected
void
initSerializer()
Initializes the serializer
Methods¶
doDeleteMultiple()¶
Delete multiple keys.
doGetMultiple()¶
Get multiple keys. Returns an array success, false on failure. Raises an EventsException if the event cannot be processed, and an Exception if any of the keys have wrong names.
doSetMultiple()¶
Sets multiple keys. Returns true on success, false on failure.
doDecrement()¶
Decrements a stored number
doDelete()¶
Deletes data from the adapter. This just checks the key and is called from the children
doGet()¶
doGetData()¶
doHas()¶
Checks if an element exists in the cache
doIncrement()¶
Increments a stored number
doSet()¶
abstract protected function doSet(
string $key,
mixed $value,
DateInterval|int|null $ttl = null
): bool;
Stores data in the adapter. If the TTL is null (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is 0 or a negative number, a delete() will be issued, since this
item has expired. If you need to set this key forever, you should use
the setForever() method.
getFilteredKeys()¶
Filters the keys array based on global and passed prefix
getPrefixedKey()¶
Returns the key requested, prefixed
getSerializedData()¶
Returns serialized data
getTtl()¶
Calculates the TTL for a cache item
getUnserializedData()¶
Returns unserialized data
initSerializer()¶
Initializes the serializer
Storage\Adapter\Weak¶
Class Source on GitHub
Weak Adapter
Capabilities: - Stores objects only, as WeakReferences; entries vanish when the referenced object is garbage-collected. - TTL is ignored; no serializer is used (none/no-op). - Counters unsupported: increment()/decrement() return false. - setForever() is equivalent to set(); getKeys() reads the in-memory list.
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\Weak
Uses DateInterval · Exception · Phalcon\Storage\SerializerFactory · WeakReference
Method Summary¶
public
__construct(SerializerFactory $factory,array $options = [])
Constructor, there are no options
public
bool
clear()
Flushes/clears the cache
public
array
getKeys( string $prefix = "" )
Stores data in the adapter
public
void
setDefaultSerializer( string $serializer )
Will never set a serializer, WeakReference cannot be serialized
public
bool
setForever(string $key,mixed $data)
For compatiblity only, there is no Forever with WeakReference.
protected
false|int
doDecrement(string $key,int $value = 1)
Decrements a stored number
protected
bool
doDelete( string $key )
Deletes data from the adapter
protected
mixed
doGet(string $key,mixed $defaultValue = null)
Reads data from the adapter
protected
bool
doHas( string $key )
Checks if an element exists in the cache
protected
false|int
doIncrement(string $key,int $value = 1)
Increments a stored number
protected
bool
doSet(string $key,mixed $value,mixed $ttl = null)
Stores data in the adapter. If the TTL is null (default) or not defined
Properties¶
protected
string|null
$fetching = null
protected
array
$options = []
protected
array
$weakList = []
Methods¶
__construct()¶
Constructor, there are no options
clear()¶
Flushes/clears the cache
getKeys()¶
Stores data in the adapter
setDefaultSerializer()¶
Will never set a serializer, WeakReference cannot be serialized
setForever()¶
For compatiblity only, there is no Forever with WeakReference.
doDecrement()¶
Decrements a stored number
doDelete()¶
Deletes data from the adapter
doGet()¶
Reads data from the adapter
doHas()¶
Checks if an element exists in the cache
doIncrement()¶
Increments a stored number
doSet()¶
Stores data in the adapter. If the TTL is null (default) or not defined
then the default TTL will be used, as set in this adapter. If the TTL
is 0 or a negative number, a delete() will be issued, since this
item has expired. If you need to set this key forever, you should use
the setForever() method.
Storage\Exception¶
Class Source on GitHub
Phalcon\Storage\Exception
Exceptions thrown in Phalcon\Storage will use this class
\ExceptionPhalcon\Storage\Exception
Storage\Exceptions\AuthenticationFailed¶
Class Source on GitHub
\ExceptionPhalcon\Storage\ExceptionPhalcon\Storage\Exceptions\AuthenticationFailed
Uses Phalcon\Storage\Exception
Method Summary¶
Methods¶
__construct()¶
Storage\Exceptions\ClusterConnectionFailed¶
Class Source on GitHub
\ExceptionPhalcon\Storage\ExceptionPhalcon\Storage\Exceptions\ClusterConnectionFailed
Uses Phalcon\Storage\Exception
Storage\Exceptions\ConnectionFailed¶
Class Source on GitHub
\ExceptionPhalcon\Storage\ExceptionPhalcon\Storage\Exceptions\ConnectionFailed
Uses Phalcon\Storage\Exception
Storage\Exceptions\DatabaseSelectionFailed¶
Class Source on GitHub
\ExceptionPhalcon\Storage\ExceptionPhalcon\Storage\Exceptions\DatabaseSelectionFailed
Uses Phalcon\Storage\Exception
Method Summary¶
Methods¶
__construct()¶
Storage\Exceptions\InvalidConfiguration¶
Class Source on GitHub
\ExceptionPhalcon\Storage\ExceptionPhalcon\Storage\Exceptions\InvalidConfiguration
Uses Phalcon\Storage\Exception
Storage\Exceptions\StorageError¶
Class Source on GitHub
\ExceptionPhalcon\Storage\ExceptionPhalcon\Storage\Exceptions\StorageError
Uses Phalcon\Storage\Exception
Storage\SerializerFactory¶
Class Source on GitHub
Phalcon\Storage\SerializerFactory
Uses Exception · Phalcon\Storage\Serializer\Base64 · Phalcon\Storage\Serializer\Igbinary · Phalcon\Storage\Serializer\Json · Phalcon\Storage\Serializer\MemcachedIgbinary · Phalcon\Storage\Serializer\MemcachedJson · Phalcon\Storage\Serializer\MemcachedPhp · Phalcon\Storage\Serializer\Msgpack · Phalcon\Storage\Serializer\None · Phalcon\Storage\Serializer\Php · Phalcon\Storage\Serializer\RedisIgbinary · Phalcon\Storage\Serializer\RedisJson · Phalcon\Storage\Serializer\RedisMsgpack · Phalcon\Storage\Serializer\RedisNone · Phalcon\Storage\Serializer\RedisPhp · Phalcon\Storage\Serializer\SerializerInterface · Phalcon\Traits\Factory\FactoryTrait
Method Summary¶
public
__construct( array $services = [] )
SerializerFactory constructor.
public
SerializerInterface
newInstance( string $name )
protected
string
getExceptionClass()
protected
array
getServices()
Returns the available adapters
Methods¶
__construct()¶
SerializerFactory constructor.
newInstance()¶
getExceptionClass()¶
getServices()¶
Returns the available adapters
Storage\Serializer\AbstractSerializer¶
Abstract Source on GitHub
@property mixed $data @property bool $isSuccess
Phalcon\Storage\Serializer\AbstractSerializer- implementsPhalcon\Storage\Serializer\SerializerInterface
Method Summary¶
public
__construct( mixed $data = null )
AbstractSerializer constructor.
public
array
__serialize()
Serialize data
public
void
__unserialize( array $data )
Unserialize data
public
mixed
getData()
public
bool
isSuccess()
Returns true if the serialize/unserialize operation was successful;
public
void
setData( mixed $data )
protected
bool
isSerializable( mixed $data )
If this returns true, then the data is returned as is
Properties¶
protected
mixed
$data = null
protected
bool
$isSuccess = true
Methods¶
__construct()¶
AbstractSerializer constructor.
__serialize()¶
Serialize data
__unserialize()¶
Unserialize data
getData()¶
isSuccess()¶
Returns true if the serialize/unserialize operation was successful;
false otherwise
setData()¶
isSerializable()¶
If this returns true, then the data is returned as is
Storage\Serializer\Base64¶
Class Source on GitHub
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\Base64
Uses Phalcon\Storage\Serializer\Exceptions\InvalidSerializationInput · Phalcon\Storage\Serializer\Exceptions\InvalidUnserializationInput · Phalcon\Traits\Php\Base64Trait
Method Summary¶
Methods¶
serialize()¶
Serializes data
unserialize()¶
Unserializes data
@retrun void
Storage\Serializer\Exceptions\InvalidSerializationInput¶
Class Source on GitHub
\InvalidArgumentExceptionPhalcon\Storage\Serializer\Exceptions\InvalidSerializationInput
Uses InvalidArgumentException
Method Summary¶
Methods¶
__construct()¶
Storage\Serializer\Exceptions\InvalidUnserializationInput¶
Class Source on GitHub
\InvalidArgumentExceptionPhalcon\Storage\Serializer\Exceptions\InvalidUnserializationInput
Uses InvalidArgumentException
Method Summary¶
Methods¶
__construct()¶
Storage\Serializer\Igbinary¶
Class Source on GitHub
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\Igbinary
Uses Phalcon\Traits\Php\IgbinaryTrait
Method Summary¶
public
mixed
serialize()
Serializes data
public
void
unserialize( mixed $data )
Unserializes data
protected
string|null
doSerialize( mixed $value )
Serialize
protected
doUnserialize( mixed $value )
Unserialize
Methods¶
serialize()¶
Serializes data
unserialize()¶
Unserializes data
doSerialize()¶
Serialize
doUnserialize()¶
Unserialize
Storage\Serializer\Json¶
Class Source on GitHub
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\Json
Uses Phalcon\Support\Helper\Json\Decode · Phalcon\Support\Helper\Json\Encode
Method Summary¶
public
__construct( mixed $data = null )
AbstractSerializer constructor.
public
mixed
serialize()
Serializes data
public
void
unserialize( mixed $data )
Unserializes data
Methods¶
__construct()¶
AbstractSerializer constructor.
serialize()¶
Serializes data
unserialize()¶
Unserializes data
Storage\Serializer\MemcachedIgbinary¶
Class Source on GitHub
Serializer using the built-in Memcached 'igbinary' serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\MemcachedIgbinary
Storage\Serializer\MemcachedJson¶
Class Source on GitHub
Serializer using the built-in Memcached 'json' serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\MemcachedJson
Storage\Serializer\MemcachedPhp¶
Class Source on GitHub
Serializer using the built-in Memcached 'php' serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\MemcachedPhp
Storage\Serializer\Msgpack¶
Class Source on GitHub
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\IgbinaryPhalcon\Storage\Serializer\Msgpack
Uses Phalcon\Traits\Php\MsgpackTrait
Method Summary¶
protected
string
doSerialize( mixed $value )
Serializes data
protected
doUnserialize( mixed $value )
Methods¶
doSerialize()¶
Serializes data
doUnserialize()¶
Storage\Serializer\None¶
Class Source on GitHub
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\MemcachedIgbinaryPhalcon\Storage\Serializer\MemcachedJsonPhalcon\Storage\Serializer\MemcachedPhpPhalcon\Storage\Serializer\RedisIgbinaryPhalcon\Storage\Serializer\RedisJsonPhalcon\Storage\Serializer\RedisMsgpackPhalcon\Storage\Serializer\RedisNonePhalcon\Storage\Serializer\RedisPhp
Method Summary¶
Methods¶
serialize()¶
Serializes data
unserialize()¶
Unserializes data
@retrun void
Storage\Serializer\Php¶
Class Source on GitHub
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\Php
Uses Phalcon\Storage\Serializer\Exceptions\InvalidUnserializationInput · Phalcon\Traits\Php\SerializeTrait
Method Summary¶
Methods¶
serialize()¶
Serializes data
unserialize()¶
Unserializes data
Storage\Serializer\RedisIgbinary¶
Class Source on GitHub
Serializer using the built-in Redis 'igbinary' serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\RedisIgbinary
Storage\Serializer\RedisJson¶
Class Source on GitHub
Serializer using the built-in Redis 'json' serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\RedisJson
Storage\Serializer\RedisMsgpack¶
Class Source on GitHub
Serializer using the built-in Redis 'msgpack' serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\RedisMsgpack
Storage\Serializer\RedisNone¶
Class Source on GitHub
Serializer using the built-in Redis 'none' serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\RedisNone
Storage\Serializer\RedisPhp¶
Class Source on GitHub
Serializer using the built-in Redis 'php' serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\RedisPhp
Storage\Serializer\SerializerInterface¶
Interface Source on GitHub
Phalcon\Storage\Serializer\SerializerInterface
Method Summary¶
public
mixed
getData()
public
mixed
serialize()
Serializes data
public
void
setData( mixed $data )
public
void
unserialize( mixed $data )
Unserializes data
Methods¶
getData()¶
serialize()¶
Serializes data
setData()¶
unserialize()¶
Unserializes data