Skip to content

Phalcon storage

NOTE

All classes are prefixed with Phalcon

Storage\Adapter\AbstractAdapter Abstract

Source on GitHub

  • Namespace

    • Phalcon\Storage\Adapter
  • Uses

    • DateInterval
    • DateTime
    • Exception
    • Phalcon\Storage\SerializerFactory
    • Phalcon\Storage\Serializer\SerializerInterface
    • Phalcon\Exception
  • Extends

  • Implements

    • AdapterInterface

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 string
 */
protected $prefix = '';

/**
 * Serializer
 *
 * @var SerializerInterface
 */
protected $serializer;

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

Methods

protected function __construct( SerializerFactory $factory, array $options = [] );
Sets parameters based on options

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

abstract public function get( string $key, mixed $defaultValue = null ): mixed;
Reads data from the adapter

abstract public function getAdapter(): mixed;
Returns the adapter - connects to the storage if not connected

public function getDefaultSerializer(): string;

abstract public function getKeys( string $prefix = string ): array;
Returns all the keys stored

public function getPrefix(): string;

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 $defaultSerializer )

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

Storage\Adapter\AdapterInterface Interface

Source on GitHub

  • Namespace

    • Phalcon\Storage\Adapter
  • Uses

    • Phalcon\Storage\Serializer\SerializerInterface
  • Extends

  • Implements

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

Storage\Adapter\Apcu

Source on GitHub

  • Namespace

    • Phalcon\Storage\Adapter
  • Uses

    • APCUIterator
    • DateInterval
    • Exception
    • Phalcon\Storage\SerializerFactory
    • Phalcon\Exception
  • Extends

    AbstractAdapter

  • Implements

Apcu adapter

Properties

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

Methods

public function __construct( SerializerFactory $factory, array $options = [] );
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 getAdapter(): mixed;
Always returns null

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

Storage\Adapter\Libmemcached

Source on GitHub

  • Namespace

    • Phalcon\Storage\Adapter
  • Uses

    • DateInterval
    • Exception
    • Phalcon\Storage\Exception
    • Phalcon\Storage\SerializerFactory
    • Phalcon\Exception
  • Extends

    AbstractAdapter

  • Implements

Libmemcached adapter

Properties

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

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

Storage\Adapter\Memory

Source on GitHub

  • Namespace

    • Phalcon\Storage\Adapter
  • Uses

    • DateInterval
    • Exception
    • Phalcon\Storage\SerializerFactory
    • Phalcon\Exception
  • Extends

    AbstractAdapter

  • Implements

Memory adapter

Properties

/**
 * @var Collection|CollectionInterface
 */
protected $data;

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

Methods

public function __construct( SerializerFactory $factory, array $options = [] );
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 getAdapter(): mixed;
Always returns null

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

Storage\Adapter\Redis

Source on GitHub

  • Namespace

    • Phalcon\Storage\Adapter
  • Uses

    • DateInterval
    • Exception
    • Phalcon\Storage\Exception
    • Phalcon\Storage\SerializerFactory
    • Phalcon\Exception
  • Extends

    AbstractAdapter

  • Implements

Redis adapter

Properties

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

Methods

public function __construct( SerializerFactory $factory, array $options = [] );
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 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 Redis server(s)

public function getKeys( string $prefix = string ): array;
Gets the keys from the adapter. Accepts an optional prefix which will filter the keys returned

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 no ttl is given, the default value will be used (3600s at the moment).

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\Exception
    • RecursiveDirectoryIterator
    • RecursiveIteratorIterator
  • Extends

    AbstractAdapter

  • Implements

Stream adapter

Properties

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

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

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 getAdapter(): mixed;
Always returns null

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

Storage\AdapterFactory

Source on GitHub

  • Namespace

    • Phalcon\Storage
  • Uses

    • Phalcon\Factory\AbstractFactory
    • Phalcon\Storage\Adapter\AdapterInterface
  • Extends

    AbstractFactory

  • Implements

This file is part of the Phalcon Framework.

(c) Phalcon Team team@phalcon.io

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 getAdapters(): array;

Storage\Exception

Source on GitHub

  • Namespace

    • Phalcon\Storage
  • Uses

  • Extends

    \Exception

  • Implements

Phalcon\Storage\Exception

Exceptions thrown in Phalcon\Storage will use this class

Storage\Serializer\AbstractSerializer Abstract

Source on GitHub

  • Namespace

    • Phalcon\Storage\Serializer
  • Uses

  • Extends

  • Implements

    • SerializerInterface

@property mixed $data @property bool $isSuccess

Properties

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

Methods

public function __construct( mixed $data = null );
Constructor

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

protected function isSerializable( mixed $data ): bool;
If this returns true, then the data returns back as is

Storage\Serializer\Base64

Source on GitHub

  • Namespace

    • Phalcon\Storage\Serializer
  • Uses

    • InvalidArgumentException
  • Extends

    AbstractSerializer

  • Implements

Methods

public function serialize(): string;
Serializes data

public function unserialize( mixed $data ): void;
Unserializes data

Storage\Serializer\Igbinary

Source on GitHub

  • Namespace

    • Phalcon\Storage\Serializer
  • Uses

  • Extends

    AbstractSerializer

  • Implements

Methods

public function serialize(): string;
Serializes data

public function unserialize( mixed $data ): void;
Unserializes data

Storage\Serializer\Json

Source on GitHub

  • Namespace

    • Phalcon\Storage\Serializer
  • Uses

    • InvalidArgumentException
    • JsonSerializable
    • Phalcon\Helper\Json\Decode
    • Phalcon\Helper\Json\Encode
  • Extends

    AbstractSerializer

  • Implements

Methods

public function serialize(): string;
Serializes data

public function unserialize( mixed $data ): void;
Unserializes data

Storage\Serializer\Msgpack

Source on GitHub

  • Namespace

    • Phalcon\Storage\Serializer
  • Uses

  • Extends

    Igbinary

  • Implements

Methods

public function serialize(): string | null;
Serializes data

public function unserialize( mixed $data ): void;
Unserializes data

Storage\Serializer\None

Source on GitHub

  • Namespace

    • Phalcon\Storage\Serializer
  • Uses

  • Extends

    AbstractSerializer

  • Implements

Methods

public function serialize(): string;
Serializes data

public function unserialize( mixed $data ): void;
Unserializes data

Storage\Serializer\Php

Source on GitHub

  • Namespace

    • Phalcon\Storage\Serializer
  • Uses

    • InvalidArgumentException
  • Extends

    AbstractSerializer

  • Implements

This file is part of the Phalcon Framework.

(c) Phalcon Team team@phalcon.io

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

Storage\Serializer\SerializerInterface Interface

Source on GitHub

  • Namespace

    • Phalcon\Storage\Serializer
  • Uses

    • Serializable
  • Extends

    Serializable

  • Implements

This file is part of the Phalcon Framework.

(c) Phalcon Team team@phalcon.io

For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.

Methods

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

Storage\SerializerFactory

Source on GitHub

  • Namespace

    • Phalcon\Storage
  • Uses

    • Phalcon\Factory\AbstractFactory
    • Phalcon\Storage\Serializer\SerializerInterface
  • Extends

    AbstractFactory

  • Implements

This file is part of the Phalcon Framework.

(c) Phalcon Team team@phalcon.io

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 getAdapters(): array;