Storage\AdapterFactory
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Phalcon\Factory\AbstractConfigFactoryPhalcon\Factory\AbstractFactoryPhalcon\Storage\AdapterFactory
Uses Phalcon\Factory\AbstractFactory · Phalcon\Storage\Adapter\AdapterInterface
Method Summary
public__construct(SerializerFactory$factory,array$services = [])AdapterFactory constructor.publicAdapterInterfacenewInstance(string$name,array$options = [])Create a new instance of the adapterprotectedstringgetExceptionClass()protectedarraygetServices()Returns the available adaptersMethods
__construct()
public function __construct(
SerializerFactory $factory,
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
Storage\Adapter\AbstractAdapter
AbstractSource on GitHubClass 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\ManagerInterface · Phalcon\Storage\SerializerFactory · Phalcon\Storage\Serializer\SerializerInterface · Phalcon\Support\Exception
Method Summary
publicboolclear()Flushes/clears the cachepublicint|booldecrement(string$key,int$value = 1)Decrements a stored numberpublicbooldelete( string$key )Deletes data from the adapterpublicbooldeleteMultiple( array$keys )Deletes data from the adapterpublicmixedget(string$key,mixed$defaultValue = null)Reads data from the adapterpublicmixedgetAdapter()Returns the adapter - connects to the storage if not connectedpublicstringgetDefaultSerializer()Name of the default serializer classpublicManagerInterface|nullgetEventsManager()Get the event managerpublicarraygetKeys( string$prefix = "" )Returns all the keys storedpublicintgetLifetime()Returns the lifetimepublicstringgetPrefix()Returns the prefixpublicSerializerInterfacegetSerializer()Get the serializerpublicboolhas( string$key )Checks if an element exists in the cachepublicint|boolincrement(string$key,int$value = 1)Increments a stored numberpublicboolset(string$key,mixed$value,mixed$ttl = null)Stores data in the adapter. If the TTL is null (default) or not definedpublicvoidsetDefaultSerializer( string$serializer )publicvoidsetEventsManager( ManagerInterface$eventsManager )Sets the event managerprotected__construct(SerializerFactory$factory,array$options = [])AbstractAdapter constructor.protectedint|booldoDecrement(string$key,int$value = 1)Decrements a stored numberprotectedbooldoDelete( string$key )Deletes data from the adapterprotectedbooldoDeleteMultiple( array$keys )Deletes multiple keys from the adapterprotectedmixeddoGet(string$key,mixed$defaultValue = null)protectedmixeddoGetData( string$key )protectedbooldoHas( string$key )Checks if an element exists in the cacheprotectedint|booldoIncrement(string$key,int$value = 1)Increments a stored numberprotectedbooldoSet(string$key,mixed$value,mixed$ttl = null)Stores data in the adapter. If the TTL is null (default) or not definedprotectedvoidfire(string$eventName,mixed$keys)Trigger an event for the eventsManager.protectedmixedgetArrVal(array$collection,mixed$index,mixed$defaultValue = null,string$cast = null)@todo Remove this when we get traitsprotectedarraygetFilteredKeys(mixed$keys,string$prefix)Filters the keys array based on global and passed prefixprotectedstringgetPrefixedKey( mixed$key )Returns the key requested, prefixedprotectedmixedgetSerializedData( mixed$content )Returns serialized dataprotectedintgetTtl( mixed$ttl )Calculates the TTL for a cache itemprotectedmixedgetUnserializedData(mixed$content,mixed$defaultValue = null)Returns unserialized dataprotectedvoidinitSerializer()Initializes the serializerProperties
protectedmixed$adapterprotectedstring$defaultSerializer = "php"Name of the default serializer classprotectedstring$eventType = "storage"EventType prefix.protectedManagerInterface|null$eventsManager = nullEvent Managerprotectedint$lifetime = 3600Name of the default TTL (time to live)protectedarray$options = []protectedstring$prefix = "ph-memo-"protectedSerializerInterface|null$serializerSerializerprotectedSerializerFactory$serializerFactorySerializer FactoryMethods
clear()
abstract public function clear(): bool;Flushes/clears the cache
decrement()
public function decrement(
string $key,
int $value = 1
): int|bool;Decrements a stored number
delete()
public function delete( string $key ): bool;Deletes data from the adapter
deleteMultiple()
public function deleteMultiple( array $keys ): bool;Deletes data from the adapter
get()
public function get(
string $key,
mixed $defaultValue = null
): mixed;Reads data from the adapter
getAdapter()
public function getAdapter(): mixed;Returns the adapter - connects to the storage if not connected
getDefaultSerializer()
public function getDefaultSerializer(): string;Name of the default serializer class
getEventsManager()
public function getEventsManager(): ManagerInterface|null;Get the event manager
getKeys()
abstract public function getKeys( string $prefix = "" ): array;Returns all the keys stored
getLifetime()
public function getLifetime(): int;Returns the lifetime
getPrefix()
public function getPrefix(): string;Returns the prefix
getSerializer()
public function getSerializer(): SerializerInterface;Get the serializer
has()
public function has( string $key ): bool;Checks if an element exists in the cache
increment()
public function increment(
string $key,
int $value = 1
): int|bool;Increments a stored number
set()
public function set(
string $key,
mixed $value,
mixed $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.
setDefaultSerializer()
public function setDefaultSerializer( string $serializer ): void;setEventsManager()
public function setEventsManager( ManagerInterface $eventsManager ): void;Sets the event manager
__construct()
protected function __construct(
SerializerFactory $factory,
array $options = []
);AbstractAdapter constructor.
doDecrement()
abstract protected function doDecrement(
string $key,
int $value = 1
): int|bool;Decrements a stored number
doDelete()
abstract protected function doDelete( string $key ): bool;Deletes data from the adapter
doDeleteMultiple()
protected function doDeleteMultiple( array $keys ): bool;Deletes multiple keys from the adapter
doGet()
protected function doGet(
string $key,
mixed $defaultValue = null
): mixed;doGetData()
protected function doGetData( string $key ): mixed;doHas()
abstract protected function doHas( string $key ): bool;Checks if an element exists in the cache
doIncrement()
abstract protected function doIncrement(
string $key,
int $value = 1
): int|bool;Increments a stored number
doSet()
abstract protected function doSet(
string $key,
mixed $value,
mixed $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.
fire()
protected function fire(
string $eventName,
mixed $keys
): void;Trigger an event for the eventsManager.
getArrVal()
protected function getArrVal(
array $collection,
mixed $index,
mixed $defaultValue = null,
string $cast = null
): mixed;@todo Remove this when we get traits
getFilteredKeys()
protected function getFilteredKeys(
mixed $keys,
string $prefix
): array;Filters the keys array based on global and passed prefix
getPrefixedKey()
protected function getPrefixedKey( mixed $key ): string;Returns the key requested, prefixed
getSerializedData()
protected function getSerializedData( mixed $content ): mixed;Returns serialized data
getTtl()
protected function getTtl( mixed $ttl ): int;Calculates the TTL for a cache item
getUnserializedData()
protected function getUnserializedData(
mixed $content,
mixed $defaultValue = null
): mixed;Returns unserialized data
initSerializer()
protected function initSerializer(): void;Initializes the serializer
Storage\Adapter\AdapterInterface
InterfaceSource on GitHubInterface for Phalcon\Logger adapters
Phalcon\Storage\Adapter\AdapterInterface
Uses Phalcon\Storage\Serializer\SerializerInterface
Method Summary
publicboolclear()Flushes/clears the cachepublicint|booldecrement(string$key,int$value = 1)Decrements a stored numberpublicbooldelete( string$key )Deletes data from the adapterpublicbooldeleteMultiple( array$keys )Deletes multiple data from the adapterpublicmixedget(string$key,mixed$defaultValue = null)Reads data from the adapterpublicmixedgetAdapter()Returns the already connected adapter or connects to the backendpublicarraygetKeys( string$prefix = "" )Returns all the keys storedpublicstringgetPrefix()Returns the prefix for the keyspublicboolhas( string$key )Checks if an element exists in the cachepublicint|boolincrement(string$key,int$value = 1)Increments a stored numberpublicboolset(string$key,mixed$value,mixed$ttl = null)Stores data in the adapter. If the TTL is null (default) or not definedpublicboolsetForever(string$key,mixed$value)Stores data in the adapter forever. The key needs to manually deletedMethods
clear()
public function clear(): bool;Flushes/clears the cache
decrement()
public function decrement(
string $key,
int $value = 1
): int|bool;Decrements a stored number
delete()
public function delete( string $key ): bool;Deletes data from the adapter
deleteMultiple()
public function deleteMultiple( array $keys ): bool;Deletes multiple data from the adapter
get()
public function get(
string $key,
mixed $defaultValue = null
): mixed;Reads data from the adapter
getAdapter()
public function getAdapter(): mixed;Returns the already connected adapter or connects to the backend server(s)
getKeys()
public function getKeys( string $prefix = "" ): array;Returns all the keys stored
getPrefix()
public function getPrefix(): string;Returns the prefix for the keys
has()
public function has( string $key ): bool;Checks if an element exists in the cache
increment()
public function increment(
string $key,
int $value = 1
): int|bool;Increments a stored number
set()
public function set(
string $key,
mixed $value,
mixed $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.
setForever()
public function setForever(
string $key,
mixed $value
): bool;Stores data in the adapter forever. The key needs to manually deleted from the adapter.
Storage\Adapter\Apcu
ClassSource on GitHubApcu adapter
@property array $options
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\Apcu
Uses APCUIterator · DateInterval · Exception · Phalcon\Storage\SerializerFactory · Phalcon\Support\Exception
Method Summary
public__construct(SerializerFactory$factory,array$options = [])Apcu constructor.publicboolclear()Flushes/clears the cachepublicarraygetKeys( string$prefix = "" )Stores data in the adapterpublicboolsetForever(string$key,mixed$value)Stores data in the adapter forever. The key needs to manually deletedprotectedint|booldoDecrement(string$key,int$value = 1)Decrements a stored numberprotectedbooldoDelete( string$key )Deletes data from the adapterprotectedbooldoDeleteMultiple( array$keys )Deletes multiple keys from APCu in a single callprotecteddoGetData( string$key )protectedbooldoHas( string$key )Checks if an element exists in the cacheprotectedint|booldoIncrement(string$key,int$value = 1)Increments a stored numberprotectedbooldoSet(string$key,mixed$value,mixed$ttl = null)Stores data in the adapter. If the TTL is null (default) or not definedprotectedbool|intphpApcuDec(mixed$key,int$step = 1)@todo Remove the below once we get traitsprotectedbool|arrayphpApcuDelete( mixed$key )protectedbool|arrayphpApcuExists( mixed$key )protectedmixedphpApcuFetch( mixed$key )protectedbool|intphpApcuInc(mixed$key,int$step = 1)protectedAPCUIterator|boolphpApcuIterator( string$pattern )protectedbool|arrayphpApcuStore(mixed$key,mixed$payload,int$ttl = 0)Properties
protectedstring$prefix = "ph-apcu-"Methods
__construct()
public function __construct(
SerializerFactory $factory,
array $options = []
);Apcu constructor.
clear()
public function clear(): bool;Flushes/clears the cache
getKeys()
public function getKeys( string $prefix = "" ): array;Stores data in the adapter
setForever()
public function setForever(
string $key,
mixed $value
): bool;Stores data in the adapter forever. The key needs to manually deleted from the adapter.
doDecrement()
protected function doDecrement(
string $key,
int $value = 1
): int|bool;Decrements a stored number
doDelete()
protected function doDelete( string $key ): bool;Deletes data from the adapter
doDeleteMultiple()
protected function doDeleteMultiple( array $keys ): bool;Deletes multiple keys from APCu in a single call
doGetData()
protected function doGetData( string $key );doHas()
protected function doHas( string $key ): bool;Checks if an element exists in the cache
doIncrement()
protected function doIncrement(
string $key,
int $value = 1
): int|bool;Increments a stored number
doSet()
protected function doSet(
string $key,
mixed $value,
mixed $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.
phpApcuDec()
protected function phpApcuDec(
mixed $key,
int $step = 1
): bool|int;@todo Remove the below once we get traits
phpApcuDelete()
protected function phpApcuDelete( mixed $key ): bool|array;phpApcuExists()
protected function phpApcuExists( mixed $key ): bool|array;phpApcuFetch()
protected function phpApcuFetch( mixed $key ): mixed;phpApcuInc()
protected function phpApcuInc(
mixed $key,
int $step = 1
): bool|int;phpApcuIterator()
protected function phpApcuIterator( string $pattern ): APCUIterator|bool;phpApcuStore()
protected function phpApcuStore(
mixed $key,
mixed $payload,
int $ttl = 0
): bool|array;Storage\Adapter\Libmemcached
ClassSource on GitHubLibmemcached adapter
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\Libmemcached
Uses DateInterval · Exception · 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.publicboolclear()Flushes/clears the cachepublicmixedgetAdapter()Returns the already connected adapter or connects to the MemcachedpublicarraygetKeys( string$prefix = "" )Stores data in the adapterpublicboolsetForever(string$key,mixed$value)Stores data in the adapter forever. The key needs to manually deletedprotectedint|booldoDecrement(string$key,int$value = 1)Decrements a stored numberprotectedbooldoDelete( string$key )Deletes data from the adapterprotectedbooldoDeleteMultiple( array$keys )Deletes multiple keys from Memcached using a single deleteMulti callprotectedbooldoHas( string$key )Checks if an element exists in the cacheprotectedint|booldoIncrement(string$key,int$value = 1)Increments a stored numberprotectedbooldoSet(string$key,mixed$value,mixed$ttl = null)Stores data in the adapter. If the TTL is null (default) or not definedProperties
protectedstring$prefix = "ph-memc-"Methods
__construct()
public function __construct(
SerializerFactory $factory,
array $options = []
);Libmemcached constructor.
clear()
public function clear(): bool;Flushes/clears the cache
getAdapter()
public function getAdapter(): mixed;Returns the already connected adapter or connects to the Memcached server(s)
getKeys()
public function getKeys( string $prefix = "" ): array;Stores data in the adapter
setForever()
public function setForever(
string $key,
mixed $value
): bool;Stores data in the adapter forever. The key needs to manually deleted from the adapter.
doDecrement()
protected function doDecrement(
string $key,
int $value = 1
): int|bool;Decrements a stored number
doDelete()
protected function doDelete( string $key ): bool;Deletes data from the adapter
doDeleteMultiple()
protected function doDeleteMultiple( array $keys ): bool;Deletes multiple keys from Memcached using a single deleteMulti call
doHas()
protected function doHas( string $key ): bool;Checks if an element exists in the cache
doIncrement()
protected function doIncrement(
string $key,
int $value = 1
): int|bool;Increments a stored number
doSet()
protected function doSet(
string $key,
mixed $value,
mixed $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.
Storage\Adapter\Memory
ClassSource on GitHubMemory adapter
@property array $data @property array $options
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\Memory
Uses DateInterval · Exception · Phalcon\Storage\SerializerFactory · Phalcon\Support\Exception
Method Summary
public__construct(SerializerFactory$factory,array$options = [])Memory constructor.publicboolclear()Flushes/clears the cachepublicarraygetKeys( string$prefix = "" )Stores data in the adapterpublicintgetMaxItems()Returns the configured store cap (0 = unlimited). See setMaxItems().publicboolsetForever(string$key,mixed$value)Stores data in the adapter forever. The key needs to manually deletedpublicstaticsetMaxItems( int$maxItems )Caps the number of items retained in the in-memory store.protectedint|booldoDecrement(string$key,int$value = 1)Decrements a stored numberprotectedbooldoDelete( string$key )Deletes data from the adapterprotecteddoGetData( string$key )protectedbooldoHas( string$key )Checks if an element exists in the cacheprotectedint|booldoIncrement(string$key,int$value = 1)Increments a stored numberprotectedbooldoSet(string$key,mixed$value,mixed$ttl = null)Stores data in the adapter. If the TTL is null (default) or not definedProperties
protectedarray$data = []protectedint$maxItems = 0Maximum 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()
public function __construct(
SerializerFactory $factory,
array $options = []
);Memory constructor.
clear()
public function clear(): bool;Flushes/clears the cache
getKeys()
public function getKeys( string $prefix = "" ): array;Stores data in the adapter
getMaxItems()
public function getMaxItems(): int;Returns the configured store cap (0 = unlimited). See setMaxItems().
setForever()
public function setForever(
string $key,
mixed $value
): bool;Stores data in the adapter forever. The key needs to manually deleted from the adapter.
setMaxItems()
public function setMaxItems( int $maxItems ): static;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()
protected function doDecrement(
string $key,
int $value = 1
): int|bool;Decrements a stored number
doDelete()
protected function doDelete( string $key ): bool;Deletes data from the adapter
doGetData()
protected function doGetData( string $key );doHas()
protected function doHas( string $key ): bool;Checks if an element exists in the cache
doIncrement()
protected function doIncrement(
string $key,
int $value = 1
): int|bool;Increments a stored number
doSet()
protected function doSet(
string $key,
mixed $value,
mixed $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.
Storage\Adapter\Redis
ClassSource on GitHubRedis adapter
@property array $options
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\Redis
Uses DateInterval · Exception · Phalcon\Storage\Exception · Phalcon\Storage\Exceptions\AuthenticationFailed · Phalcon\Storage\Exceptions\ConnectionFailed · Phalcon\Storage\Exceptions\DatabaseSelectionFailed · Phalcon\Storage\SerializerFactory · Phalcon\Support\Exception
Method Summary
public__construct(SerializerFactory$factory,array$options = [])Redis constructor.publicboolclear()Flushes/clears the cachepublicmixedgetAdapter()Returns the already connected adapter or connects to the RedispublicarraygetKeys( string$prefix = "" )Stores data in the adapterpublicboolsetForever(string$key,mixed$value)Stores data in the adapter forever. The key needs to manually deletedprotectedint|booldoDecrement(string$key,int$value = 1)Decrements a stored numberprotectedbooldoDelete( string$key )Deletes data from the adapterprotectedbooldoDeleteMultiple( array$keys )Deletes multiple keys from Redis using a single unlink callprotectedbooldoHas( string$key )Checks if an element exists in the cacheprotectedint|booldoIncrement(string$key,int$value = 1)Increments a stored numberprotectedbooldoSet(string$key,mixed$value,mixed$ttl = null)Stores data in the adapter. If the TTL is null (default) or not definedProperties
protectedstring$prefix = "ph-reds-"Methods
__construct()
public function __construct(
SerializerFactory $factory,
array $options = []
);Redis constructor.
clear()
public function clear(): bool;Flushes/clears the cache
getAdapter()
public function getAdapter(): mixed;Returns the already connected adapter or connects to the Redis server(s)
getKeys()
public function getKeys( string $prefix = "" ): array;Stores data in the adapter
setForever()
public function setForever(
string $key,
mixed $value
): bool;Stores data in the adapter forever. The key needs to manually deleted from the adapter.
doDecrement()
protected function doDecrement(
string $key,
int $value = 1
): int|bool;Decrements a stored number
doDelete()
protected function doDelete( string $key ): bool;Deletes data from the adapter
doDeleteMultiple()
protected function doDeleteMultiple( array $keys ): bool;Deletes multiple keys from Redis using a single unlink call
doHas()
protected function doHas( string $key ): bool;Checks if an element exists in the cache
doIncrement()
protected function doIncrement(
string $key,
int $value = 1
): int|bool;Increments a stored number
doSet()
protected function doSet(
string $key,
mixed $value,
mixed $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.
Storage\Adapter\RedisCluster
ClassSource on GitHubRedisCluster adapter
@property array $options
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\RedisPhalcon\Storage\Adapter\RedisCluster
Uses Phalcon\Storage\Exceptions\ClusterConnectionFailed · Phalcon\Storage\SerializerFactory
Method Summary
public__construct(SerializerFactory$factory,array$options = [])You can create and connect to a cluster either by passing it one or morepublicboolclear()Flushes/clears the cachepublicmixedgetAdapter()Returns the already connected adapter or connects to the RedisProperties
protectedstring$prefix = "ph-redc-"Methods
__construct()
public function __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 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()
public function clear(): bool;Flushes/clears the cache
getAdapter()
public function getAdapter(): mixed;Returns the already connected adapter or connects to the Redis Cluster server(s)
Storage\Adapter\Stream
ClassSource on GitHubStream adapter
@property string $storageDir @property array $options
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\Stream
Uses DateInterval · FilesystemIterator · Iterator · Phalcon\Storage\Exceptions\InvalidConfiguration · Phalcon\Storage\SerializerFactory · Phalcon\Support\Exception · RecursiveDirectoryIterator · RecursiveIteratorIterator
Method Summary
public__construct(SerializerFactory$factory,array$options = [])Stream constructor.publicboolclear()Flushes/clears the cachepublicarraygetKeys( string$prefix = "" )Stores data in the adapterpublicboolsetForever(string$key,mixed$value)Stores data in the adapter forever. The key needs to manually deletedprotectedint|booldoDecrement(string$key,int$value = 1)Decrements a stored numberprotectedbooldoDelete( string$key )Deletes data from the adapterprotectedmixeddoGet(string$key,mixed$defaultValue = null)Reads data from the adapterprotectedbooldoHas( string$key )Checks if an element exists in the cache and is not expiredprotectedint|booldoIncrement(string$key,int$value = 1)Increments a stored numberprotectedbooldoSet(string$key,mixed$value,mixed$ttl = null)Stores data in the adapter. If the TTL is null (default) or not definedprotectedboolphpFileExists( string$filename )@todo Remove the methods below when we get traitsprotectedstring|boolphpFileGetContents( string$filename )protectedint|boolphpFilePutContents(string$filename,mixed$data,int$flags = 0,mixed$context = null)protectedmixedphpFopen(string$filename,string$mode)protectedboolphpUnlink( string$filename )Properties
protectedstring$prefix = "ph-strm"protectedstring$storageDir = ""Methods
__construct()
public function __construct(
SerializerFactory $factory,
array $options = []
);Stream constructor.
clear()
public function clear(): bool;Flushes/clears the cache
getKeys()
public function getKeys( string $prefix = "" ): array;Stores data in the adapter
setForever()
public function setForever(
string $key,
mixed $value
): bool;Stores data in the adapter forever. The key needs to manually deleted from the adapter.
doDecrement()
protected function doDecrement(
string $key,
int $value = 1
): int|bool;Decrements a stored number
doDelete()
protected function doDelete( string $key ): bool;Deletes data from the adapter
doGet()
protected function doGet(
string $key,
mixed $defaultValue = null
): mixed;Reads data from the adapter
doHas()
protected function doHas( string $key ): bool;Checks if an element exists in the cache and is not expired
doIncrement()
protected function doIncrement(
string $key,
int $value = 1
): int|bool;Increments a stored number
doSet()
protected function doSet(
string $key,
mixed $value,
mixed $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.
phpFileExists()
protected function phpFileExists( string $filename ): bool;@todo Remove the methods below when we get traits
phpFileGetContents()
protected function phpFileGetContents( string $filename ): string|bool;phpFilePutContents()
protected function phpFilePutContents(
string $filename,
mixed $data,
int $flags = 0,
mixed $context = null
): int|bool;phpFopen()
protected function phpFopen(
string $filename,
string $mode
): mixed;phpUnlink()
protected function phpUnlink( string $filename ): bool;Storage\Adapter\Weak
ClassSource on GitHubWeak Adapter
Phalcon\Storage\Adapter\AbstractAdapterPhalcon\Storage\Adapter\Weak
Uses DateInterval · Exception · Phalcon\Storage\SerializerFactory · Phalcon\Storage\Serializer\SerializerInterface · Phalcon\Support\Exception
Method Summary
public__construct(SerializerFactory$factory,array$options = [])Constructor, there are no optionspublicboolclear()Flushes/clears the cachepublicarraygetKeys( string$prefix = "" )Stores data in the adapterpublicvoidsetDefaultSerializer( string$serializer )will never set a serializer, WeakReference cannot be serializedpublicboolsetForever(string$key,mixed$value)For compatiblity only, there is no Forever with WeakReference.protectedint|booldoDecrement(string$key,int$value = 1)Decrements a stored number - not supported for WeakReferenceprotectedbooldoDelete( string$key )Deletes data from the adapterprotectedmixeddoGet(string$key,mixed$defaultValue = null)Reads data from the adapterprotectedbooldoHas( string$key )Checks if an element exists in the cacheprotectedint|booldoIncrement(string$key,int$value = 1)Increments a stored number - not supported for WeakReferenceprotectedbooldoSet(string$key,mixed$value,mixed$ttl = null)Stores data in the adapter. If the TTL is null (default) or not definedProperties
protectedint|null$fetching = nullprotectedarray$options = []protectedarray$weakList = []Methods
__construct()
public function __construct(
SerializerFactory $factory,
array $options = []
);Constructor, there are no options
clear()
public function clear(): bool;Flushes/clears the cache
getKeys()
public function getKeys( string $prefix = "" ): array;Stores data in the adapter
setDefaultSerializer()
public function setDefaultSerializer( string $serializer ): void;will never set a serializer, WeakReference cannot be serialized
setForever()
public function setForever(
string $key,
mixed $value
): bool;For compatiblity only, there is no Forever with WeakReference.
doDecrement()
protected function doDecrement(
string $key,
int $value = 1
): int|bool;Decrements a stored number - not supported for WeakReference
doDelete()
protected function doDelete( string $key ): bool;Deletes data from the adapter
doGet()
protected function doGet(
string $key,
mixed $defaultValue = null
): mixed;Reads data from the adapter
doHas()
protected function doHas( string $key ): bool;Checks if an element exists in the cache
doIncrement()
protected function doIncrement(
string $key,
int $value = 1
): int|bool;Increments a stored number - not supported for WeakReference
doSet()
protected function doSet(
string $key,
mixed $value,
mixed $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.
Storage\Exception
ClassSource on GitHubPhalcon\Storage\Exception
Exceptions thrown in Phalcon\Storage will use this class
\ExceptionPhalcon\Storage\Exception
Storage\Exceptions\AuthenticationFailed
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Storage\ExceptionPhalcon\Storage\Exceptions\AuthenticationFailed
Uses Phalcon\Storage\Exception
Method Summary
Methods
__construct()
public function __construct();Storage\Exceptions\ClusterConnectionFailed
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Storage\ExceptionPhalcon\Storage\Exceptions\ClusterConnectionFailed
Uses Phalcon\Storage\Exception
Storage\Exceptions\ConnectionFailed
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Storage\ExceptionPhalcon\Storage\Exceptions\ConnectionFailed
Uses Phalcon\Storage\Exception
Storage\Exceptions\DatabaseSelectionFailed
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Storage\ExceptionPhalcon\Storage\Exceptions\DatabaseSelectionFailed
Uses Phalcon\Storage\Exception
Method Summary
Methods
__construct()
public function __construct();Storage\Exceptions\InvalidConfiguration
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Storage\ExceptionPhalcon\Storage\Exceptions\InvalidConfiguration
Uses Phalcon\Storage\Exception
Storage\Exceptions\StorageError
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Storage\ExceptionPhalcon\Storage\Exceptions\StorageError
Uses Phalcon\Storage\Exception
Storage\SerializerFactory
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Phalcon\Factory\AbstractConfigFactoryPhalcon\Factory\AbstractFactoryPhalcon\Storage\SerializerFactory
Uses Phalcon\Factory\AbstractFactory · Phalcon\Storage\Serializer\SerializerInterface
Method Summary
public__construct( array$services = [] )SerializerFactory constructor.publicSerializerInterfacenewInstance( string$name )protectedstringgetExceptionClass()protectedarraygetServices()Returns the available adaptersMethods
__construct()
public function __construct( array $services = [] );SerializerFactory constructor.
newInstance()
public function newInstance( string $name ): SerializerInterface;getExceptionClass()
protected function getExceptionClass(): string;getServices()
protected function getServices(): array;Returns the available adapters
Storage\Serializer\AbstractSerializer
AbstractSource 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.publicarray__serialize()Serialize datapublicvoid__unserialize( array$data )Unserialize datapublicmixedgetData()publicboolisSuccess()Returns true if the serialize/unserialize operation was successful;publicvoidsetData( mixed$data )protectedboolisSerializable( mixed$data )If this returns true, then the data is returned as isProperties
protectedmixed$data = nullprotectedbool$isSuccess = trueMethods
__construct()
public function __construct( mixed $data = null );AbstractSerializer constructor.
__serialize()
public function __serialize(): array;Serialize data
__unserialize()
public function __unserialize( array $data ): void;Unserialize data
getData()
public function getData(): mixed;isSuccess()
public function isSuccess(): bool;Returns true if the serialize/unserialize operation was successful;
false otherwise
setData()
public function setData( mixed $data ): void;isSerializable()
protected function isSerializable( mixed $data ): bool;If this returns true, then the data is returned as is
Storage\Serializer\Base64
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\Base64
Uses Phalcon\Storage\Serializer\Exceptions\InvalidSerializationInput · Phalcon\Storage\Serializer\Exceptions\InvalidUnserializationInput
Method Summary
publicstringserialize()Serializes datapublicvoidunserialize( mixed$data )Unserializes dataprotectedphpBase64Decode(string$input,bool$strict = false)Wrapper for base64_decodeMethods
serialize()
public function serialize(): string;Serializes data
unserialize()
public function unserialize( mixed $data ): void;Unserializes data
@retrun void
phpBase64Decode()
protected function phpBase64Decode(
string $input,
bool $strict = false
);Wrapper for base64_decode
Storage\Serializer\Exceptions\InvalidSerializationInput
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\InvalidArgumentExceptionPhalcon\Storage\Serializer\Exceptions\InvalidSerializationInput
Method Summary
Methods
__construct()
public function __construct();Storage\Serializer\Exceptions\InvalidUnserializationInput
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\InvalidArgumentExceptionPhalcon\Storage\Serializer\Exceptions\InvalidUnserializationInput
Method Summary
Methods
__construct()
public function __construct();Storage\Serializer\Igbinary
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\Igbinary
Method Summary
publicmixedserialize()Serializes datapublicvoidunserialize( mixed$data )Unserializes dataprotectedstring|nulldoSerialize( mixed$value )SerializeprotecteddoUnserialize( mixed$value )Unserializeprotectedstring|nullphpIgbinarySerialize( mixed$value )Wrapper for igbinary_serializeMethods
serialize()
public function serialize(): mixed;Serializes data
unserialize()
public function unserialize( mixed $data ): void;Unserializes data
doSerialize()
protected function doSerialize( mixed $value ): string|null;Serialize
doUnserialize()
protected function doUnserialize( mixed $value );Unserialize
phpIgbinarySerialize()
protected function phpIgbinarySerialize( mixed $value ): string|null;Wrapper for igbinary_serialize
Storage\Serializer\Json
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\Json
Uses InvalidArgumentException · Phalcon\Support\Helper\Json\Decode · Phalcon\Support\Helper\Json\Encode
Method Summary
public__construct( mixed$data = null )AbstractSerializer constructor.publicmixedserialize()Serializes datapublicvoidunserialize( mixed$data )Unserializes dataMethods
__construct()
public function __construct( mixed $data = null );AbstractSerializer constructor.
serialize()
public function serialize(): mixed;Serializes data
unserialize()
public function unserialize( mixed $data ): void;Unserializes data
Storage\Serializer\MemcachedIgbinary
ClassSource on GitHubSerializer using the built-in Memcached ‘igbinary’ serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\MemcachedIgbinary
Storage\Serializer\MemcachedJson
ClassSource on GitHubSerializer using the built-in Memcached ‘json’ serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\MemcachedJson
Storage\Serializer\MemcachedPhp
ClassSource on GitHubSerializer using the built-in Memcached ‘php’ serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\MemcachedPhp
Storage\Serializer\Msgpack
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\IgbinaryPhalcon\Storage\Serializer\Msgpack
Method Summary
Methods
doSerialize()
protected function doSerialize( mixed $value ): string;Serializes data
doUnserialize()
protected function doUnserialize( mixed $value );Storage\Serializer\None
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
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()
public function serialize(): mixed;Serializes data
unserialize()
public function unserialize( mixed $data ): void;Unserializes data
@retrun void
Storage\Serializer\Php
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\Php
Uses Phalcon\Storage\Serializer\Exceptions\InvalidUnserializationInput
Method Summary
Methods
serialize()
public function serialize(): mixed;Serializes data
unserialize()
public function unserialize( mixed $data ): void;Unserializes data
Storage\Serializer\RedisIgbinary
ClassSource on GitHubSerializer using the built-in Redis ‘igbinary’ serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\RedisIgbinary
Storage\Serializer\RedisJson
ClassSource on GitHubSerializer using the built-in Redis ‘json’ serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\RedisJson
Storage\Serializer\RedisMsgpack
ClassSource on GitHubSerializer using the built-in Redis ‘msgpack’ serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\RedisMsgpack
Storage\Serializer\RedisNone
ClassSource on GitHubSerializer using the built-in Redis ‘none’ serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\RedisNone
Storage\Serializer\RedisPhp
ClassSource on GitHubSerializer using the built-in Redis ‘php’ serializer
Phalcon\Storage\Serializer\AbstractSerializerPhalcon\Storage\Serializer\NonePhalcon\Storage\Serializer\RedisPhp
Storage\Serializer\SerializerInterface
InterfaceSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
Phalcon\Storage\Serializer\SerializerInterface
Method Summary
publicmixedgetData()publicmixedserialize()Serializes datapublicvoidsetData( mixed$data )publicvoidunserialize( mixed$data )Unserializes dataMethods
getData()
public function getData(): mixed;serialize()
public function serialize(): mixed;Serializes data
setData()
public function setData( mixed $data ): void;unserialize()
public function unserialize( mixed $data ): void;Unserializes data