Sections

Abstract Class Phalcon\Storage\Adapter\AbstractAdapter

Source on GitHub

Namespace Phalcon\Storage\Adapter   Uses DateInterval, DateTime, Exception, Phalcon\Storage\Serializer\SerializerInterface, Phalcon\Storage\SerializerFactory, Phalcon\Support\Exception   Implements AdapterInterface

Class AbstractAdapter

Properties

/**
 * @var mixed
 */
protected adapter;

/**
 * Name of the default serializer class
 *
 * @var string
 */
protected defaultSerializer = php;

/**
 * Name of the default TTL (time to live)
 *
 * @var int
 */
protected lifetime = 3600;

/**
 * @var array
 */
protected options;

/**
 * @var string
 */
protected prefix = ph-memo-;

/**
 * Serializer
 *
 * @var SerializerInterface|null
 */
protected serializer;

/**
 * Serializer Factory
 *
 * @var SerializerFactory
 */
protected serializerFactory;

Methods

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

AbstractAdapter constructor.

abstract public function clear(): bool;

Flushes/clears the cache

abstract public function decrement( string $key, int $value = int ): int | bool;

Decrements a stored number

abstract public function delete( string $key ): bool;

Deletes data from the adapter

public function get( string $key, mixed $defaultValue = null ): mixed;

Reads data from the adapter

public function getAdapter(): mixed;

Returns the adapter - connects to the storage if not connected

public function getDefaultSerializer(): string;

Name of the default serializer class

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

Returns all the keys stored

public function getPrefix(): string;

Returns the prefix

abstract public function has( string $key ): bool;

Checks if an element exists in the cache

abstract public function increment( string $key, int $value = int ): int | bool;

Increments a stored number

abstract public function set( string $key, mixed $value, mixed $ttl = null ): bool;

Stores data in the adapter

public function setDefaultSerializer( string $serializer ): void;
protected function doGet( string $key );
protected function getArrVal( array $collection, mixed $index, mixed $defaultValue = null, string $cast = null ): mixed;

@todo Remove this when we get traits

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

Filters the keys array based on global and passed prefix

protected function getPrefixedKey( mixed $key ): string;

Returns the key requested, prefixed

protected function getSerializedData( mixed $content ): mixed;

Returns serialized data

protected function getTtl( mixed $ttl ): int;

Calculates the TTL for a cache item

protected function getUnserializedData( mixed $content, mixed $defaultValue = null ): mixed;

Returns unserialized data

protected function initSerializer(): void;

Initializes the serializer

@throws SupportException

Interface Phalcon\Storage\Adapter\AdapterInterface

Source on GitHub

Namespace Phalcon\Storage\Adapter   Uses Phalcon\Storage\Serializer\SerializerInterface

Interface for Phalcon\Logger adapters

Methods

public function clear(): bool;

Flushes/clears the cache

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

Decrements a stored number

public function delete( string $key ): bool;

Deletes data from the adapter

public function get( string $key, mixed $defaultValue = null ): mixed;

Reads data from the adapter

public function getAdapter(): mixed;

Returns the already connected adapter or connects to the backend server(s)

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

Returns all the keys stored

public function getPrefix(): string;

Returns the prefix for the keys

public function has( string $key ): bool;

Checks if an element exists in the cache

public function increment( string $key, int $value = int ): int | bool;

Increments a stored number

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.

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

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

Class Phalcon\Storage\Adapter\Apcu

Source on GitHub

Namespace Phalcon\Storage\Adapter   Uses APCuIterator, DateInterval, Exception, Phalcon\Storage\SerializerFactory, Phalcon\Support\Exception   Extends AbstractAdapter

Apcu adapter

Properties

/**
 * @var string
 */
protected prefix = ph-apcu-;

Methods

public function __construct( SerializerFactory $factory, array $options = [] );

Apcu constructor.

public function clear(): bool;

Flushes/clears the cache

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

Decrements a stored number

public function delete( string $key ): bool;

Reads data from the adapter

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

Stores data in the adapter

public function has( string $key ): bool;

Checks if an element exists in the cache

public function increment( string $key, int $value = int ): int | bool;

Increments a stored number

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.

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

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

protected function doGet( string $key );
protected function phpApcuDec( mixed $key, int $step = int, mixed $success = null, int $ttl = int ): bool | int;

@todo Remove the below once we get traits

protected function phpApcuDelete( mixed $key ): bool | array;
protected function phpApcuExists( mixed $key ): bool | array;
protected function phpApcuFetch( mixed $key, mixed $success = null ): mixed;
protected function phpApcuInc( mixed $key, int $step = int, mixed $success = null, int $ttl = int ): bool | int;
protected function phpApcuIterator( string $pattern ): APCuIterator | bool;
protected function phpApcuStore( mixed $key, mixed $payload, int $ttl = int ): bool | array;

Class Phalcon\Storage\Adapter\Libmemcached

Source on GitHub

Namespace Phalcon\Storage\Adapter   Uses DateInterval, Exception, Phalcon\Storage\Exception, Phalcon\Storage\SerializerFactory, Phalcon\Support\Exception   Extends AbstractAdapter

Libmemcached adapter

Properties

/**
 * @var string
 */
protected prefix = ph-memc-;

Methods

public function __construct( SerializerFactory $factory, array $options = [] );

Libmemcached constructor.

public function clear(): bool;

Flushes/clears the cache

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

Decrements a stored number

public function delete( string $key ): bool;

Reads data from the adapter

public function getAdapter(): mixed;

Returns the already connected adapter or connects to the Memcached server(s)

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

Stores data in the adapter

public function has( string $key ): bool;

Checks if an element exists in the cache

public function increment( string $key, int $value = int ): int | bool;

Increments a stored number

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.

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

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

Class Phalcon\Storage\Adapter\Memory

Source on GitHub

Namespace Phalcon\Storage\Adapter   Uses DateInterval, Exception, Phalcon\Storage\SerializerFactory, Phalcon\Support\Exception   Extends AbstractAdapter

Memory adapter

Properties

/**
 * @var array
 */
protected data;

Methods

public function __construct( SerializerFactory $factory, array $options = [] );

Memory constructor.

public function clear(): bool;

Flushes/clears the cache

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

Decrements a stored number

public function delete( string $key ): bool;

Deletes data from the adapter

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

Stores data in the adapter

public function has( string $key ): bool;

Checks if an element exists in the cache

public function increment( string $key, int $value = int ): int | bool;

Increments a stored number

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.

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

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

protected function doGet( string $key );

Class Phalcon\Storage\Adapter\Redis

Source on GitHub

Namespace Phalcon\Storage\Adapter   Uses DateInterval, Exception, Phalcon\Storage\Exception, Phalcon\Storage\SerializerFactory, Phalcon\Support\Exception   Extends AbstractAdapter

Redis adapter

Properties

/**
 * @var string
 */
protected prefix = ph-reds-;

Methods

public function __construct( SerializerFactory $factory, array $options = [] );

Redis constructor.

public function clear(): bool;

Flushes/clears the cache

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

Decrements a stored number

public function delete( string $key ): bool;

Reads data from the adapter

public function getAdapter(): mixed;

Returns the already connected adapter or connects to the Redis server(s)

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

Stores data in the adapter

public function has( string $key ): bool;

Checks if an element exists in the cache

public function increment( string $key, int $value = int ): int | bool;

Increments a stored number

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.

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

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

Class Phalcon\Storage\Adapter\Stream

Source on GitHub

Namespace Phalcon\Storage\Adapter   Uses DateInterval, FilesystemIterator, Iterator, Phalcon\Storage\Exception, Phalcon\Storage\SerializerFactory, Phalcon\Storage\Traits\StorageErrorHandlerTrait, Phalcon\Support\Exception, RecursiveDirectoryIterator, RecursiveIteratorIterator   Extends AbstractAdapter

Stream adapter

Properties

/**
 * @var string
 */
protected prefix = ph-strm;

/**
 * @var string
 */
protected storageDir = ;

Methods

public function __construct( SerializerFactory $factory, array $options = [] );

Stream constructor.

public function clear(): bool;

Flushes/clears the cache

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

Decrements a stored number

public function delete( string $key ): bool;

Reads data from the adapter

public function get( string $key, mixed $defaultValue = null ): mixed;

Reads data from the adapter

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

Stores data in the adapter

public function has( string $key ): bool;

Checks if an element exists in the cache and is not expired

public function increment( string $key, int $value = int ): int | bool;

Increments a stored number

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.

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

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

protected function phpFileExists( string $filename ): bool;

@todo Remove the methods below when we get traits

protected function phpFileGetContents( string $filename ): string | bool;
protected function phpFilePutContents( string $filename, mixed $data, int $flags = int, mixed $context = null ): int | bool;
protected function phpFopen( string $filename, string $mode ): mixed;
protected function phpUnlink( string $filename ): bool;

Class Phalcon\Storage\AdapterFactory

Source on GitHub

Namespace Phalcon\Storage   Uses Phalcon\Factory\AbstractFactory, Phalcon\Storage\Adapter\AdapterInterface   Extends AbstractFactory

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

Properties

/**
 * @var SerializerFactory
 */
private serializerFactory;

Methods

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

AdapterFactory constructor.

public function newInstance( string $name, array $options = [] ): AdapterInterface;

Create a new instance of the adapter

protected function getExceptionClass(): string;
protected function getServices(): array;

Returns the available adapters

Class Phalcon\Storage\Exception

Source on GitHub

Namespace Phalcon\Storage   Extends \Exception

Phalcon\Storage\Exception

Exceptions thrown in Phalcon\Storage will use this class

Abstract Class Phalcon\Storage\Serializer\AbstractSerializer

Source on GitHub

Namespace Phalcon\Storage\Serializer   Implements SerializerInterface

Properties

/**
 * @var mixed
 */
protected data;

/**
 * @var bool
 */
protected isSuccess = true;

Methods

public function __construct( mixed $data = null );

AbstractSerializer constructor.

public function __serialize(): array;

Serialize data

public function __unserialize( array $data ): void;

Unserialize data

public function getData();
public function isSuccess(): bool;

Returns true if the serialize/unserialize operation was successful; false otherwise

public function setData( mixed $data ): void;
protected function isSerializable( mixed $data ): bool;

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

Class Phalcon\Storage\Serializer\Base64

Source on GitHub

Namespace Phalcon\Storage\Serializer   Uses InvalidArgumentException   Extends AbstractSerializer

Methods

public function serialize(): string;

Serializes data

public function unserialize( mixed $data ): void;

Unserializes data

protected function phpBase64Decode( string $input, bool $strict = bool );

Wrapper for base64_decode

Class Phalcon\Storage\Serializer\Igbinary

Source on GitHub

Namespace Phalcon\Storage\Serializer   Extends AbstractSerializer

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

Methods

public function serialize();

Serializes data

public function unserialize( mixed $data ): void;

Unserializes data

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

Serialize

protected function doUnserialize( mixed $value );

Unserialize

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

Wrapper for igbinary_serialize

Class Phalcon\Storage\Serializer\Json

Source on GitHub

Namespace Phalcon\Storage\Serializer   Uses InvalidArgumentException, JsonSerializable   Extends AbstractSerializer

Methods

public function serialize();

Serializes data

public function unserialize( mixed $data ): void;

Unserializes data

Class Phalcon\Storage\Serializer\MemcachedIgbinary

Source on GitHub

Namespace Phalcon\Storage\Serializer   Extends None

Serializer using the built-in Memcached ‘igbinary’ serializer

Class Phalcon\Storage\Serializer\MemcachedJson

Source on GitHub

Namespace Phalcon\Storage\Serializer   Extends None

Serializer using the built-in Memcached ‘json’ serializer

Class Phalcon\Storage\Serializer\MemcachedPhp

Source on GitHub

Namespace Phalcon\Storage\Serializer   Extends None

Serializer using the built-in Memcached ‘php’ serializer

Class Phalcon\Storage\Serializer\Msgpack

Source on GitHub

Namespace Phalcon\Storage\Serializer   Extends Igbinary

Methods

protected function doSerialize( mixed $value ): string;

Serializes data

protected function doUnserialize( mixed $value );

Class Phalcon\Storage\Serializer\None

Source on GitHub

Namespace Phalcon\Storage\Serializer   Extends AbstractSerializer

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

Methods

public function serialize(): mixed;

Serializes data

public function unserialize( mixed $data ): void;

Unserializes data

Class Phalcon\Storage\Serializer\Php

Source on GitHub

Namespace Phalcon\Storage\Serializer   Uses InvalidArgumentException   Extends AbstractSerializer

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

Methods

public function serialize(): string;

Serializes data

public function unserialize( mixed $data ): void;

Unserializes data

Class Phalcon\Storage\Serializer\RedisIgbinary

Source on GitHub

Namespace Phalcon\Storage\Serializer   Extends None

Serializer using the built-in Redis ‘igbinary’ serializer

Class Phalcon\Storage\Serializer\RedisJson

Source on GitHub

Namespace Phalcon\Storage\Serializer   Extends None

Serializer using the built-in Redis ‘json’ serializer

Class Phalcon\Storage\Serializer\RedisMsgpack

Source on GitHub

Namespace Phalcon\Storage\Serializer   Extends None

Serializer using the built-in Redis ‘msgpack’ serializer

Class Phalcon\Storage\Serializer\RedisNone

Source on GitHub

Namespace Phalcon\Storage\Serializer   Extends None

Serializer using the built-in Redis ‘none’ serializer

Class Phalcon\Storage\Serializer\RedisPhp

Source on GitHub

Namespace Phalcon\Storage\Serializer   Extends None

Serializer using the built-in Redis ‘php’ serializer

Interface Phalcon\Storage\Serializer\SerializerInterface

Source on GitHub

Namespace Phalcon\Storage\Serializer   Uses Serializable   Extends Serializable

Methods

public function getData(): mixed;
public function setData( mixed $data ): void;

Class Phalcon\Storage\SerializerFactory

Source on GitHub

Namespace Phalcon\Storage   Uses Phalcon\Factory\AbstractFactory, Phalcon\Storage\Serializer\SerializerInterface   Extends AbstractFactory

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

Methods

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

SerializerFactory constructor.

public function newInstance( string $name ): SerializerInterface;
protected function getExceptionClass(): string;
protected function getServices(): array;

Returns the available adapters