Skip to content

Phalcon Storage

Updated View as Markdown

Storage\AdapterFactory

ClassSource on GitHub

Uses Exception · Phalcon\Contracts\Storage\StorageTypes · Phalcon\Factory\AbstractFactory · 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 · Throwable

Method Summary

Methods

Public · 2

__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

Protected · 2

getExceptionClass()

protected function getExceptionClass(): string;

getServices()

protected function getServices(): array;

Returns the available adapters

Storage\Adapter\AbstractAdapter

AbstractSource on GitHub

Storage AbstractAdapter

Uses DateInterval · DateTime · Exception · Phalcon\Contracts\Storage\StorageTypes · Phalcon\Events\EventsAwareInterface · Phalcon\Events\ManagerInterface · Phalcon\Events\Traits\EventsAwareTrait · Phalcon\Storage\SerializerFactory · Phalcon\Storage\Serializer\SerializerInterface · Phalcon\Traits\Support\Helper\Arr\GetTrait

Method Summary

publicboolclear()Flushes/clears the cachepublicfalse|intdecrement(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 adapter - connects to the storage if not connectedpublicstringgetDefaultSerializer()Name of the default serializer classpublicarraygetKeys( string$prefix = "" )Returns all the keys storedpublicintgetLifetime()Returns the lifetimepublicstringgetPrefix()Returns the prefixpublicSerializerInterface|nullgetSerializer()Get the serializerpublicboolhas( string$key )Checks if an element exists in the cachepublicfalse|intincrement(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 )protected__construct(SerializerFactory$serializerFactory,array$options = [])AbstractAdapter constructor.protectedfalse|intdoDecrement(string$key,int$value = 1)Decrements a stored numberprotectedbooldoDelete( string$key )Deletes data from the adapterprotectedbooldoDeleteMultiple( array$keys )Deletes multiple data from the adapterprotectedmixeddoGet(string$key,mixed$defaultValue = null)protectedmixeddoGetData( string$key )protectedbooldoHas( string$key )Checks if an element exists in the cacheprotectedfalse|intdoIncrement(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 definedprotectedarraygetFilteredKeys(mixed$keys,string$prefix)Filters the keys array based on global and passed prefixprotectedstringgetKeyWithoutPrefix( string$key )Check if the key has the prefix and remove it, otherwise just return theprotectedstringgetPrefixedKey( 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 serializer

Properties

protectedmixed$adapter
protectedstring$defaultSerializer = "php"Name of the default serializer class
protectedstring$eventType = "storage"EventType prefix.
protectedint$lifetime = 3600Name of the default TTL (time to live)
protectedarray<string, mixed>$options = []
protectedstring$prefix = "ph-memo-"
protectedSerializerInterface|null$serializer = null
protectedSerializerFactory$serializerFactory
protectedbool$stripPrefix = trueWhether 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

Public · 15

clear()

abstract public function clear(): bool;

Flushes/clears the cache

decrement()

public function decrement(
    string $key,
    int $value = 1
): false|int;

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 adapter - connects to the storage if not connected

getDefaultSerializer()

public function getDefaultSerializer(): string;

Name of the default serializer class

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|null;

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
): false|int;

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;
Protected · 16

__construct()

protected function __construct(
    SerializerFactory $serializerFactory,
    array $options = []
);

AbstractAdapter constructor.

doDecrement()

abstract protected function doDecrement(
    string $key,
    int $value = 1
): false|int;

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 data 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
): false|int;

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.

getFilteredKeys()

protected function getFilteredKeys(
    mixed $keys,
    string $prefix
): array;

Filters the keys array based on global and passed prefix

getKeyWithoutPrefix()

protected function getKeyWithoutPrefix( string $key ): string;

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()

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 GitHub

Interface for Phalcon\Logger adapters

Uses DateInterval · Phalcon\Contracts\Storage\StorageTypes

Method Summary

Methods

Public · 12

clear()

public function clear(): bool;

Flushes/clears the cache

decrement()

public function decrement(
    string $key,
    int $value = 1
): false|int;

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
): false|int;

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 $data
): bool;

Stores data in the adapter forever. The key needs to be manually deleted from the adapter.

Storage\Adapter\Apcu

ClassSource 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.

Uses APCUIterator · Exception · Phalcon\Contracts\Storage\StorageTypes · Phalcon\Storage\SerializerFactory · Phalcon\Traits\Php\ApcuTrait

Method Summary

Properties

protectedstring$prefix = "ph-apcu-"

Methods

Public · 4

__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 $data
): bool;

Stores data in the adapter forever. The key needs to manually deleted from the adapter.

Protected · 7

doDecrement()

protected function doDecrement(
    string $key,
    int $value = 1
): false|int;

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 ): mixed;

doHas()

protected function doHas( string $key ): bool;

Checks if an element exists in the cache

doIncrement()

protected function doIncrement(
    string $key,
    int $value = 1
): false|int;

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\Libmemcached

ClassSource 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.

Uses DateInterval · Exception · Memcached · Phalcon\Contracts\Storage\StorageTypes · Phalcon\Storage\Exception · Phalcon\Storage\Exceptions\ConnectionFailed · Phalcon\Storage\Exceptions\InvalidConfiguration · Phalcon\Storage\SerializerFactory · Phalcon\Support\Exception

Method Summary

Properties

protectedstring$prefix = "ph-memc-"

Methods

Public · 5

__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 $data
): bool;

Stores data in the adapter forever. The key needs to be manually deleted from the adapter.

Protected · 6

doDecrement()

protected function doDecrement(
    string $key,
    int $value = 1
): false|int;

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
): false|int;

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 GitHub

Memory adapter

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.

Uses Exception · Phalcon\Contracts\Storage\StorageTypes · Phalcon\Storage\SerializerFactory

Method Summary

Properties

protectedarray<string, mixed>$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

Public · 6

__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 $data
): 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.

Protected · 6

doDecrement()

protected function doDecrement(
    string $key,
    int $value = 1
): false|int;

Decrements a stored number

doDelete()

protected function doDelete( string $key ): bool;

Deletes data from the adapter

doGetData()

protected function doGetData( string $key ): mixed;

doHas()

protected function doHas( string $key ): bool;

Checks if an element exists in the cache

doIncrement()

protected function doIncrement(
    string $key,
    int $value = 1
): false|int;

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 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\Contracts\Storage\StorageTypes · Phalcon\Storage\Exception · Phalcon\Storage\Exceptions\AuthenticationFailed · Phalcon\Storage\Exceptions\ConnectionFailed · Phalcon\Storage\Exceptions\DatabaseSelectionFailed · Phalcon\Storage\SerializerFactory · Redis · RedisException

Method Summary

Properties

protectedstring$prefix = "ph-reds-"

Methods

Public · 5

__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)

The return type is deliberately left wide: RedisCluster extends this adapter and hands back a RedisCluster client, which is not a Redis. Callers inside this class narrow it to RedisService locally.

getKeys()

public function getKeys( string $prefix = "" ): array;

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()

public function setForever(
    string $key,
    mixed $data
): bool;

Stores data in the adapter forever. The key needs to manually deleted from the adapter.

Protected · 7

doDecrement()

protected function doDecrement(
    string $key,
    int $value = 1
): false|int;

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
): false|int;

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.

getDefaultOptions()

protected function getDefaultOptions( array $options ): array;

The parameter is the raw, user supplied options array; RedisCluster overrides this method with its own set of keys, so the two signatures have to agree on the wider type.

Storage\Adapter\RedisCluster

ClassSource 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.

Uses Phalcon\Contracts\Storage\StorageTypes · Phalcon\Storage\Exceptions\ClusterConnectionFailed · Phalcon\Storage\SerializerFactory · Phalcon\Support\Exception · Redis · RedisCluster · Throwable

Method Summary

Properties

protectedstring$prefix = "ph-redc-"

Methods

Public · 4

__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 server(s)

getKeys()

public function getKeys( string $prefix = "" ): array;

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.

Protected · 1

getDefaultOptions()

protected function getDefaultOptions( array $options ): array;

Storage\Adapter\Stream

ClassSource 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.

Uses FilesystemIterator · Iterator · Phalcon\Contracts\Storage\StorageTypes · 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 · SplFileInfo

Method Summary

Properties

protectedstring$prefix = "ph-strm"
protectedstring$storageDir = ""

Methods

Public · 4

__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 $data
): bool;

Stores data in the adapter forever. The key needs to manually deleted from the adapter.

Protected · 6

doDecrement()

protected function doDecrement(
    string $key,
    int $value = 1
): false|int;

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
): false|int;

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\Weak

ClassSource 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.

Uses Exception · Phalcon\Contracts\Storage\StorageTypes · Phalcon\Storage\SerializerFactory · WeakReference

Method Summary

Properties

protectedstring|null$fetching = null
protectedarray<string, mixed>$options = []
protectedarray<string, WeakReference<object>>$weakList = []

Methods

Public · 5

__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 $data
): bool;

For compatiblity only, there is no Forever with WeakReference.

Protected · 6

doDecrement()

protected function doDecrement(
    string $key,
    int $value = 1
): false|int;

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
): false|int;

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 GitHub

Phalcon\Storage\Exception

Exceptions thrown in Phalcon\Storage will use this class

Storage\Exceptions\AuthenticationFailed

ClassSource on GitHub

Uses Phalcon\Storage\Exception

Method Summary

Methods

Public · 1

__construct()

public function __construct();

Storage\Exceptions\ClusterConnectionFailed

ClassSource on GitHub

Uses Phalcon\Storage\Exception

Storage\Exceptions\ConnectionFailed

ClassSource on GitHub

Uses Phalcon\Storage\Exception

Storage\Exceptions\DatabaseSelectionFailed

ClassSource on GitHub

Uses Phalcon\Storage\Exception

Method Summary

Methods

Public · 1

__construct()

public function __construct();

Storage\Exceptions\InvalidConfiguration

ClassSource on GitHub

Uses Phalcon\Storage\Exception

Storage\Exceptions\StorageError

ClassSource on GitHub

Uses Phalcon\Storage\Exception

Storage\SerializerFactory

ClassSource on GitHub

Uses Exception · Phalcon\Contracts\Storage\StorageTypes · Phalcon\Factory\AbstractFactory · 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 · Throwable

Method Summary

Methods

Public · 2

__construct()

public function __construct( array $services = [] );

SerializerFactory constructor.

newInstance()

public function newInstance( string $name ): SerializerInterface;
Protected · 2

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

Uses Phalcon\Contracts\Storage\StorageTypes

Method Summary

Properties

protectedmixed$data = null
protectedbool$isSuccess = true

Methods

Public · 6

__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;
Protected · 1

isSerializable()

protected function isSerializable( mixed $data ): bool;

If this returns true, then the data is returned as is

Storage\Serializer\Base64

ClassSource on GitHub

Uses Phalcon\Storage\Serializer\Exceptions\InvalidSerializationInput · Phalcon\Storage\Serializer\Exceptions\InvalidUnserializationInput · Phalcon\Traits\Php\Base64Trait

Method Summary

Methods

Public · 2

serialize()

public function serialize(): string;

Serializes data

unserialize()

public function unserialize( mixed $data ): void;

Unserializes data

Storage\Serializer\Exceptions\InvalidSerializationInput

ClassSource on GitHub
  • \InvalidArgumentException
    • Phalcon\Storage\Serializer\Exceptions\InvalidSerializationInput

Uses InvalidArgumentException

Method Summary

Methods

Public · 1

__construct()

public function __construct();

Storage\Serializer\Exceptions\InvalidUnserializationInput

ClassSource on GitHub
  • \InvalidArgumentException
    • Phalcon\Storage\Serializer\Exceptions\InvalidUnserializationInput

Uses InvalidArgumentException

Method Summary

Methods

Public · 1

__construct()

public function __construct();

Storage\Serializer\Igbinary

ClassSource on GitHub

Uses Phalcon\Traits\Php\IgbinaryTrait

Method Summary

Methods

Public · 2

serialize()

public function serialize(): mixed;

Serializes data

unserialize()

public function unserialize( mixed $data ): void;

Unserializes data

Protected · 2

doSerialize()

protected function doSerialize( mixed $value ): string|null;

Serialize

doUnserialize()

protected function doUnserialize( mixed $value );

Unserialize

Storage\Serializer\Json

ClassSource on GitHub

Uses Phalcon\Support\Helper\Json\Decode · Phalcon\Support\Helper\Json\Encode

Method Summary

Methods

Public · 3

__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 GitHub

Serializer using the built-in Memcached ‘igbinary’ serializer

Storage\Serializer\MemcachedJson

ClassSource on GitHub

Serializer using the built-in Memcached ‘json’ serializer

Storage\Serializer\MemcachedPhp

ClassSource on GitHub

Serializer using the built-in Memcached ‘php’ serializer

Storage\Serializer\Msgpack

ClassSource on GitHub

Uses Phalcon\Traits\Php\MsgpackTrait

Method Summary

Methods

Protected · 2

doSerialize()

protected function doSerialize( mixed $value ): string;

Serializes data

doUnserialize()

protected function doUnserialize( mixed $value );

Storage\Serializer\None

ClassSource on GitHub

Method Summary

Methods

Public · 2

serialize()

public function serialize(): mixed;

Serializes data

unserialize()

public function unserialize( mixed $data ): void;

Unserializes data

Storage\Serializer\Php

ClassSource on GitHub

Uses Phalcon\Storage\Serializer\Exceptions\InvalidUnserializationInput · Phalcon\Traits\Php\SerializeTrait

Method Summary

Methods

Public · 2

serialize()

public function serialize(): mixed;

Serializes data

unserialize()

public function unserialize( mixed $data ): void;

Unserializes data

Storage\Serializer\RedisIgbinary

ClassSource on GitHub

Serializer using the built-in Redis ‘igbinary’ serializer

Storage\Serializer\RedisJson

ClassSource on GitHub

Serializer using the built-in Redis ‘json’ serializer

Storage\Serializer\RedisMsgpack

ClassSource on GitHub

Serializer using the built-in Redis ‘msgpack’ serializer

Storage\Serializer\RedisNone

ClassSource on GitHub

Serializer using the built-in Redis ‘none’ serializer

Storage\Serializer\RedisPhp

ClassSource on GitHub

Serializer using the built-in Redis ‘php’ serializer

Storage\Serializer\SerializerInterface

InterfaceSource on GitHub
  • Phalcon\Storage\Serializer\SerializerInterface

Method Summary

Methods

Public · 4

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

Type to search…

↑↓ navigate↵ selectEsc close