Skip to content

Phalcon cache

NOTE

All classes are prefixed with Phalcon

Cache\Cache

Source on GitHub

  • Namespace

    • Phalcon\Cache
  • Uses

    • DateInterval
    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Cache\Exception\InvalidArgumentException
  • Extends

    AbstractCache

  • Implements

This component offers caching capabilities for your application. Phalcon\Cache implements PSR-16.

Properties

/**
 * The adapter
 *
 * @var AdapterInterface
 */
protected $adapter;

Methods

public function __construct( AdapterInterface $adapter );
Constructor.

public function clear(): bool;
Wipes clean the entire cache's keys.

public function delete( mixed $key ): bool;
Delete an item from the cache by its unique key.

public function deleteMultiple( mixed $keys ): bool;
Deletes multiple cache items in a single operation.

public function get( mixed $key, mixed $defaultValue = null ): mixed;
Fetches a value from the cache.

public function getAdapter(): AdapterInterface

public function getMultiple( mixed $keys, mixed $defaultValue = null ): mixed;
Obtains multiple cache items by their unique keys.

public function has( mixed $key ): bool;
Determines whether an item is present in the cache.

public function set( mixed $key, mixed $value, mixed $ttl = null ): bool;
Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.

public function setMultiple( mixed $values, mixed $ttl = null ): bool;
Persists a set of key => value pairs in the cache, with an optional TTL.

protected function checkKey( mixed $key ): void;
Checks the key. If it contains invalid characters an exception is thrown

protected function checkKeys( mixed $keys ): void;
Checks the key. If it contains invalid characters an exception is thrown

Cache\Adapter\AdapterInterface Interface

Source on GitHub

  • Namespace

    • Phalcon\Cache\Adapter
  • Uses

    • Phalcon\Storage\Adapter\AdapterInterface
  • Extends

    StorageAdapterInterface

  • Implements

Interface for Phalcon\Cache adapters

Cache\Adapter\Apcu

Source on GitHub

  • Namespace

    • Phalcon\Cache\Adapter
  • Uses

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Storage\Adapter\Apcu
  • Extends

    StorageApcu

  • Implements

    • CacheAdapterInterface

Apcu adapter

Cache\Adapter\Libmemcached

Source on GitHub

  • Namespace

    • Phalcon\Cache\Adapter
  • Uses

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Storage\Adapter\Libmemcached
  • Extends

    StorageLibmemcached

  • Implements

    • CacheAdapterInterface

Libmemcached adapter

Cache\Adapter\Memory

Source on GitHub

  • Namespace

    • Phalcon\Cache\Adapter
  • Uses

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Storage\Adapter\Memory
  • Extends

    StorageMemory

  • Implements

    • CacheAdapterInterface

Memory adapter

Cache\Adapter\Redis

Source on GitHub

  • Namespace

    • Phalcon\Cache\Adapter
  • Uses

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Storage\Adapter\Redis
  • Extends

    StorageRedis

  • Implements

    • CacheAdapterInterface

Redis adapter

Cache\Adapter\Stream

Source on GitHub

  • Namespace

    • Phalcon\Cache\Adapter
  • Uses

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Storage\Adapter\Stream
  • Extends

    StorageStream

  • Implements

    • CacheAdapterInterface

Stream adapter

Cache\AdapterFactory

Source on GitHub

  • Namespace

    • Phalcon\Cache
  • Uses

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Cache\Exception\Exception
    • Phalcon\Factory\AbstractFactory
    • Phalcon\Storage\SerializerFactory
  • Extends

    AbstractFactory

  • Implements

Factory to create Cache adapters

Properties

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

Methods

public function __construct( SerializerFactory $factory = null, array $services = [] );
AdapterFactory constructor.

public function newInstance( string $name, array $options = [] ): AdapterInterface;
Create a new instance of the adapter

protected function getAdapters(): array;
Returns the available adapters

Cache\CacheFactory

Source on GitHub

  • Namespace

    • Phalcon\Cache
  • Uses

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Cache\Cache
    • Phalcon\Cache\Exception\Exception
    • Phalcon\Config\ConfigInterface
    • Phalcon\Factory\AbstractConfigFactory
  • Extends

    AbstractConfigFactory

  • Implements

Creates a new Cache class

Properties

/**
 * @var AdapterFactory
 */
protected $adapterFactory;

Methods

public function __construct( AdapterFactory $factory );
Constructor

public function load( mixed $config ): mixed;
Factory to create an instance from a Config object

public function newInstance( string $name, array $options = [] ): CacheInterface;
Constructs a new Cache instance.

Cache\Exception\Exception

Source on GitHub

  • Namespace

    • Phalcon\Cache\Exception
  • Uses

  • Extends

    \Exception

  • Implements

Exceptions thrown in Phalcon\Cache will use this class

Cache\Exception\InvalidArgumentException

Source on GitHub

  • Namespace

    • Phalcon\Cache\Exception
  • Uses

  • Extends

    \Exception

  • Implements

Exceptions thrown in Phalcon\Cache will use this class