跳转到内容

Phalcon缓存

注意

所有类都以前缀命名Phalcon

缓存\AbstractCacheAbstract

GitHub上的源码

  • 命名空间

    • Phalcon\Cache
  • 使用

    • DateInterval
    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Cache\Exception\InvalidArgumentException
    • Phalcon\Events\EventsAwareInterface
    • Phalcon\Events\ManagerInterface
    • Traversable
  • 继承

  • 实现

    • CacheInterface
    • EventsAwareInterface

该组件为您的应用程序提供缓存功能。

属性

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

/**
 * Event Manager
 *
 * @var ManagerInterface|null
 */
protected $eventsManager;

方法

public function __construct( AdapterInterface $adapter );
构造函数。

public function getAdapter(): AdapterInterface;
返回当前适配器

public function getEventsManager(): ManagerInterface | null;
获取事件管理器

public function setEventsManager( ManagerInterface $eventsManager ): void;
设置事件管理器

protected function checkKey( string $key ): void;
检查键。如果它包含无效字符,则会抛出异常

protected function checkKeys( mixed $keys ): void;
检查键。如果它包含无效字符,则会抛出异常

protected function doClear(): bool;
清除整个缓存的所有键。

protected function doDelete( string $key ): bool;
根据唯一键从缓存中删除一项。

protected function doDeleteMultiple( mixed $keys ): bool;
在单个操作中删除多个缓存项。

protected function doGet( string $key, mixed $defaultValue = null ): mixed;
从缓存中获取一个值。

protected function doGetMultiple( mixed $keys, mixed $defaultValue = null ): array;
根据其唯一键获取多个缓存项。

protected function doHas( string $key ): bool;
确定某项是否存在于缓存中。

protected function doSet( string $key, mixed $value, mixed $ttl = null ): bool;
将数据持久化到缓存中,通过键唯一引用,并可选设置过期TTL时间。

protected function doSetMultiple( mixed $values, mixed $ttl = null ): bool;
将一组键 => 值对持久化到缓存中,并可选设置TTL。

protected function fire( string $eventName, mixed $keys ): void;
触发事件管理器的事件。

abstract protected function getExceptionClass(): string;
返回将用于抛出异常的异常类

缓存\Adapter\AdapterInterfaceInterface

GitHub上的源码

  • 命名空间

    • Phalcon\Cache\Adapter
  • 使用

    • Phalcon\Storage\Adapter\AdapterInterface
  • 继承

    StorageAdapterInterface

  • 实现

Phalcon\Cache适配器的接口

缓存\Adapter\Apcu

GitHub上的源码

  • 命名空间

    • Phalcon\Cache\Adapter
  • 使用

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Storage\Adapter\Apcu
  • 继承

    StorageApcu

  • 实现

    • CacheAdapterInterface

Apcu适配器

属性

//
protected $eventType = 'cache';

缓存\Adapter\Libmemcached

GitHub上的源码

  • 命名空间

    • Phalcon\Cache\Adapter
  • 使用

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Storage\Adapter\Libmemcached
  • 继承

    StorageLibmemcached

  • 实现

    • CacheAdapterInterface

Libmemcached适配器

属性

//
protected $eventType = 'cache';

缓存\Adapter\Memory

GitHub上的源码

  • 命名空间

    • Phalcon\Cache\Adapter
  • 使用

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Storage\Adapter\Memory
  • 继承

    StorageMemory

  • 实现

    • CacheAdapterInterface

内存适配器

属性

//
protected $eventType = 'cache';

缓存\Adapter\Redis

GitHub上的源码

  • 命名空间

    • Phalcon\Cache\Adapter
  • 使用

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Storage\Adapter\Redis
  • 继承

    StorageRedis

  • 实现

    • CacheAdapterInterface

Redis适配器

属性

//
protected $eventType = 'cache';

缓存\Adapter\Stream

GitHub上的源码

  • 命名空间

    • Phalcon\Cache\Adapter
  • 使用

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Storage\Adapter\Stream
  • 继承

    StorageStream

  • 实现

    • CacheAdapterInterface

Stream适配器

属性

//
protected $eventType = 'cache';

缓存\Adapter\Weak

GitHub上的源码

  • 命名空间

    • Phalcon\Cache\Adapter
  • 使用

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Storage\Adapter\Weak
  • 继承

    StorageWeak

  • 实现

    • CacheAdapterInterface
  • 基于WeakReference实现的WeakCache */

属性

//
protected $eventType = 'cache';

缓存\AdapterFactory

GitHub上的源码

  • 命名空间

    • Phalcon\Cache
  • 使用

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Cache\Exception\Exception
    • Phalcon\Factory\AbstractFactory
    • Phalcon\Storage\SerializerFactory
  • 继承

    AbstractFactory

  • 实现

创建缓存适配器的工厂

属性

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

方法

public function __construct( SerializerFactory $factory, array $services = [] );
AdapterFactory构造函数。

public function newInstance( string $name, array $options = [] ): AdapterInterface;
创建适配器的新实例

protected function getExceptionClass(): string;

protected function getServices(): array;
返回可用的适配器

缓存\Cache

GitHub上的源码

  • 命名空间

    • Phalcon\Cache
  • 使用

    • DateInterval
    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Cache\Exception\InvalidArgumentException
  • 继承

    AbstractCache

  • 实现

该组件为您的应用程序提供缓存功能。

方法

public function clear(): bool;
清除整个缓存的所有键。

public function delete( string $key ): bool;
根据唯一键从缓存中删除一项。

public function deleteMultiple( mixed $keys ): bool;
在单个操作中删除多个缓存项。

public function get( string $key, mixed $defaultValue = null );
从缓存中获取一个值。

public function getMultiple( mixed $keys, mixed $defaultValue = null );
根据其唯一键获取多个缓存项。

public function has( string $key ): bool;
确定某项是否存在于缓存中。

public function set( string $key, mixed $value, mixed $ttl = null ): bool;
将数据持久化到缓存中,通过键唯一引用,并可选设置过期TTL时间。

public function setMultiple( mixed $values, mixed $ttl = null ): bool;
将一组键 => 值对持久化到缓存中,并可选设置TTL。

protected function getExceptionClass(): string;
返回将用于抛出异常的异常类

缓存\CacheFactory

GitHub上的源码

  • 命名空间

    • Phalcon\Cache
  • 使用

    • Phalcon\Cache\Adapter\AdapterInterface
    • Phalcon\Cache\Cache
    • Phalcon\Cache\Exception\Exception
    • Phalcon\Config\ConfigInterface
    • Phalcon\Factory\AbstractConfigFactory
  • 继承

    AbstractConfigFactory

  • 实现

创建一个新的缓存类

属性

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

方法

public function __construct( AdapterFactory $factory );
构造函数

public function load( mixed $config ): CacheInterface;
从Config对象创建实例的工厂

public function newInstance( string $name, array $options = [] ): CacheInterface;
构造一个新的缓存实例。

protected function getExceptionClass(): string;

缓存\CacheInterfaceInterface

GitHub上的源码

  • 命名空间

    • Phalcon\Cache
  • 使用

    • DateInterval
    • Phalcon\Cache\Exception\InvalidArgumentException
  • 继承

  • 实现

Phalcon\Cache\Cache的接口

方法

public function clear(): bool;
清除整个缓存的所有键。

public function delete( string $key ): bool;
根据唯一键从缓存中删除一项。

public function deleteMultiple( mixed $keys ): bool;
在单个操作中删除多个缓存项。

public function get( string $key, mixed $defaultValue = null );
从缓存中获取一个值。

public function getMultiple( mixed $keys, mixed $defaultValue = null );
根据其唯一键获取多个缓存项。

public function has( string $key ): bool;
确定某项是否存在于缓存中。

public function set( string $key, mixed $value, mixed $ttl = null ): bool;
将数据持久化到缓存中,通过键唯一引用,并可选设置过期TTL时间。

public function setMultiple( mixed $values, mixed $ttl = null ): bool;
将一组键 => 值对持久化到缓存中,并可选设置TTL。

缓存\Exception\Exception

GitHub上的源码

  • 命名空间

    • Phalcon\Cache\Exception
  • 使用

  • 继承

    \Exception

  • 实现

在Phalcon\Cache中抛出的异常将使用此类

缓存\Exception\InvalidArgumentException

GitHub上的源码

  • 命名空间

    • Phalcon\Cache\Exception
  • 使用

  • 继承

    \Exception

  • 实现

在Phalcon\Cache中抛出的异常将使用此类

无噪 Logo
无噪文档
25 年 6 月翻译
文档源↗