跳转到内容

Phalcon 存储

注意

所有类都以前缀命名Phalcon

存储\适配器\抽象适配器Abstract

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Adapter
  • 使用

    • DateInterval
    • DateTime
    • Exception
    • Phalcon\Events\EventsAwareInterface
    • Phalcon\Events\ManagerInterface
    • Phalcon\Storage\SerializerFactory
    • Phalcon\Storage\Serializer\SerializerInterface
    • Phalcon\Support\Exception
  • 继承

  • 实现

    • AdapterInterface
    • EventsAwareInterface

类 AbstractAdapter

@包名 Phalcon\Storage\Adapter

@属性 混合类型 $adapter @属性 字符串 $defaultSerializer @属性 整数 $lifetime @属性 数组 $options @属性 字符串 $prefix @属性 序列化器接口 $serializer @属性 序列化器工厂 $serializerFactory

属性

/**
 * @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;

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

/**
 * EventType prefix.
 *
 * @var string
 */
protected $eventType = storage;

方法

protected function __construct( SerializerFactory $factory, array $options = [] );
AbstractAdapter 构造函数。

abstract public function clear(): bool;
清空/清除缓存

abstract public function decrement( string $key, int $value = int ): int | bool;
减少存储的数字

abstract public function delete( string $key ): bool;
从适配器中删除数据

public function get( string $key, mixed $defaultValue = null ): mixed;
从适配器读取数据

public function getAdapter(): mixed;
返回适配器 - 如果未连接则连接至存储

public function getDefaultSerializer(): string;
默认序列化器类的名称

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

abstract public function getKeys( string $prefix = string ): array;
返回所有已存储的键

public function getLifetime(): int;
返回生存时间

public function getPrefix(): string;
返回前缀

public function getSerializer(): SerializerInterface;
获取序列化器

abstract public function has( string $key ): bool;
检查某个元素是否存在缓存中

abstract public function increment( string $key, int $value = int ): int | bool;
增加存储的数字

abstract public function set( string $key, mixed $value, mixed $ttl = null ): bool;
在适配器中存储数据

public function setDefaultSerializer( string $serializer ): void;

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

protected function doGet( string $key );

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

@变量 字符串 $eventName @变量 混合类型 $keys

protected function getArrVal( array $collection, mixed $index, mixed $defaultValue = null, string $cast = null ): mixed;
@todo 当我们获得特性时,删除这个

protected function getFilteredKeys( mixed $keys, string $prefix ): array;
根据全局和传入的前缀过滤键数组

protected function getPrefixedKey( mixed $key ): string;
返回请求的键,并加上前缀

protected function getSerializedData( mixed $content ): mixed;
返回序列化后的数据

protected function getTtl( mixed $ttl ): int;
计算缓存项的 TTL

protected function getUnserializedData( mixed $content, mixed $defaultValue = null ): mixed;
返回反序列化的数据

protected function initSerializer(): void;
初始化序列化器

@抛出 异常

存储\适配器\适配器接口Interface

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Adapter
  • 使用

    • Phalcon\Storage\Serializer\SerializerInterface
  • 继承

  • 实现

Phalcon\Logger适配器的接口

方法

public function clear(): bool;
清空/清除缓存

public function decrement( string $key, int $value = int ): int | bool;
减少存储的数字

public function delete( string $key ): bool;
从适配器中删除数据

public function get( string $key, mixed $defaultValue = null ): mixed;
从适配器读取数据

public function getAdapter(): mixed;
返回已连接的适配器或连接到后端服务器(们)

public function getKeys( string $prefix = string ): array;
返回所有已存储的键

public function getPrefix(): string;
返回键的前缀

public function has( string $key ): bool;
检查某个元素是否存在缓存中

public function increment( string $key, int $value = int ): int | bool;
增加存储的数字

public function set( string $key, mixed $value, mixed $ttl = null ): bool;
在适配器中存储数据。如果TTL是null(默认)或未定义,则使用在此适配器中设置的默认TTL。如果TTL是0或负数,将发出一个delete()因为此缓存项已过期。如果你需要永久设置此键,应使用setForever()方法设置容器。

public function setForever( string $key, mixed $value ): bool;
将数据永久存储在适配器中。该键需要手动从适配器删除。

存储\适配器\Apcu

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Adapter
  • 使用

    • APCUIterator
    • DateInterval
    • Exception
    • Phalcon\Storage\SerializerFactory
    • Phalcon\Support\Exception
  • 继承

    AbstractAdapter

  • 实现

Apcu适配器

@属性 数组 $options

属性

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

方法

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

public function clear(): bool;
清空/清除缓存

public function decrement( string $key, int $value = int ): int | bool;
减少存储的数字

public function delete( string $key ): bool;
从适配器读取数据

public function getKeys( string $prefix = string ): array;
在适配器中存储数据

public function has( string $key ): bool;
检查某个元素是否存在缓存中

public function increment( string $key, int $value = int ): int | bool;
增加存储的数字

public function set( string $key, mixed $value, mixed $ttl = null ): bool;
在适配器中存储数据。如果TTL是null(默认)或未定义,则使用在此适配器中设置的默认TTL。如果TTL是0或负数,将发出一个delete()因为此缓存项已过期。如果你需要永久设置此键,应使用setForever()方法设置容器。

public function setForever( string $key, mixed $value ): bool;
将数据永久存储在适配器中。该键需要手动从适配器删除。

protected function doGet( string $key );

protected function phpApcuDec( mixed $key, int $step = int ): bool | int;
@待办事项 等到我们得到 Traits 后移除以下代码

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

存储\适配器\Libmemcached

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Adapter
  • 使用

    • DateInterval
    • Exception
    • Phalcon\Storage\Exception
    • Phalcon\Storage\SerializerFactory
    • Phalcon\Support\Exception
  • 继承

    AbstractAdapter

  • 实现

Libmemcached适配器

属性

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

方法

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

public function clear(): bool;
清空/清除缓存

public function decrement( string $key, int $value = int ): int | bool;
减少存储的数字

public function delete( string $key ): bool;
从适配器读取数据

public function getAdapter(): mixed;
返回已经连接的适配器或者连接到 Memcached 服务器(们)

public function getKeys( string $prefix = string ): array;
在适配器中存储数据

public function has( string $key ): bool;
检查某个元素是否存在缓存中

public function increment( string $key, int $value = int ): int | bool;
增加存储的数字

public function set( string $key, mixed $value, mixed $ttl = null ): bool;
在适配器中存储数据。如果TTL是null(默认)或未定义,则使用在此适配器中设置的默认TTL。如果TTL是0或负数,将发出一个delete()因为此缓存项已过期。如果你需要永久设置此键,应使用setForever()方法设置容器。

public function setForever( string $key, mixed $value ): bool;
将数据永久存储在适配器中。该键需要手动从适配器删除。

存储\适配器\Memory

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Adapter
  • 使用

    • DateInterval
    • Exception
    • Phalcon\Storage\SerializerFactory
    • Phalcon\Support\Exception
  • 继承

    AbstractAdapter

  • 实现

内存适配器

@属性 数组 $data @属性 数组 $options

属性

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

方法

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

public function clear(): bool;
清空/清除缓存

public function decrement( string $key, int $value = int ): int | bool;
减少存储的数字

public function delete( string $key ): bool;
从适配器中删除数据

public function getKeys( string $prefix = string ): array;
在适配器中存储数据

public function has( string $key ): bool;
检查某个元素是否存在缓存中

public function increment( string $key, int $value = int ): int | bool;
增加存储的数字

public function set( string $key, mixed $value, mixed $ttl = null ): bool;
在适配器中存储数据。如果TTL是null(默认)或未定义,则使用在此适配器中设置的默认TTL。如果TTL是0或负数,将发出一个delete()因为此缓存项已过期。如果你需要永久设置此键,应使用setForever()方法设置容器。

public function setForever( string $key, mixed $value ): bool;
将数据永久存储在适配器中。该键需要手动从适配器删除。

protected function doGet( string $key );

存储\适配器\Redis

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Adapter
  • 使用

    • DateInterval
    • Exception
    • Phalcon\Storage\Exception
    • Phalcon\Storage\SerializerFactory
    • Phalcon\Support\Exception
  • 继承

    AbstractAdapter

  • 实现

Redis适配器

@属性 数组 $options

属性

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

方法

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

public function clear(): bool;
清空/清除缓存

public function decrement( string $key, int $value = int ): int | bool;
减少存储的数字

public function delete( string $key ): bool;
从适配器读取数据

public function getAdapter(): mixed;
返回已经连接的适配器或者连接到 Redis 服务器(们)

public function getKeys( string $prefix = string ): array;
在适配器中存储数据

public function has( string $key ): bool;
检查某个元素是否存在缓存中

public function increment( string $key, int $value = int ): int | bool;
增加存储的数字

public function set( string $key, mixed $value, mixed $ttl = null ): bool;
在适配器中存储数据。如果TTL是null(默认)或未定义,则使用在此适配器中设置的默认TTL。如果TTL是0或负数,将发出一个delete()因为此缓存项已过期。如果你需要永久设置此键,应使用setForever()方法设置容器。

public function setForever( string $key, mixed $value ): bool;
将数据永久存储在适配器中。该键需要手动从适配器删除。

存储\适配器\Stream

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Adapter
  • 使用

    • DateInterval
    • FilesystemIterator
    • Iterator
    • Phalcon\Storage\Exception
    • Phalcon\Storage\SerializerFactory
    • Phalcon\Storage\Traits\StorageErrorHandlerTrait
    • Phalcon\Support\Exception
    • RecursiveDirectoryIterator
    • RecursiveIteratorIterator
  • 继承

    AbstractAdapter

  • 实现

Stream适配器

@属性 字符串 $storageDir @属性 数组 $options

属性

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

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

方法

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

public function clear(): bool;
清空/清除缓存

public function decrement( string $key, int $value = int ): int | bool;
减少存储的数字

public function delete( string $key ): bool;
从适配器读取数据

public function get( string $key, mixed $defaultValue = null ): mixed;
从适配器读取数据

public function getKeys( string $prefix = string ): array;
在适配器中存储数据

public function has( string $key ): bool;
检查元素是否存在于缓存中且尚未过期

public function increment( string $key, int $value = int ): int | bool;
增加存储的数字

public function set( string $key, mixed $value, mixed $ttl = null ): bool;
在适配器中存储数据。如果TTL是null(默认)或未定义,则使用在此适配器中设置的默认TTL。如果TTL是0或负数,将发出一个delete()因为此缓存项已过期。如果你需要永久设置此键,应使用setForever()方法设置容器。

public function setForever( string $key, mixed $value ): bool;
将数据永久存储在适配器中。该键需要手动从适配器删除。

protected function phpFileExists( string $filename ): bool;
@待办事项 当我们获得 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;

存储\适配器\Weak

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Adapter
  • 使用

    • DateInterval
    • Exception
    • Phalcon\Storage\SerializerFactory
    • Phalcon\Storage\Serializer\SerializerInterface
    • Phalcon\Support\Exception
  • 继承

    AbstractAdapter

  • 实现

  • 弱引用适配器 */

属性

/**
 *
 *
 * @var int|null
 */
protected $fetching;

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

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

方法

public function __construct( SerializerFactory $factory, array $options = [] );
构造函数,无任何选项

public function clear(): bool;
清空/清除缓存

public function decrement( string $key, int $value = int ): int | bool;
减少存储的数字

public function delete( string $key ): bool;
从适配器中删除数据

public function get( string $key, mixed $defaultValue = null ): mixed;
从适配器读取数据

public function getKeys( string $prefix = string ): array;
在适配器中存储数据

public function has( string $key ): bool;
检查某个元素是否存在缓存中

public function increment( string $key, int $value = int ): int | bool;
增加存储的数字

public function set( string $key, mixed $value, mixed $ttl = null ): bool;
在适配器中存储数据。如果TTL是null(默认)或未定义,则使用在此适配器中设置的默认TTL。如果TTL是0或负数,将发出一个delete()因为此缓存项已过期。如果你需要永久设置此键,应使用setForever()方法设置容器。

public function setDefaultSerializer( string $serializer ): void;
永远不会设置序列化器,WeakReference 无法被序列化

public function setForever( string $key, mixed $value ): bool;
仅为兼容性存在,WeakReference 没有永久保存功能。

存储\适配器工厂

GitHub上的源码

  • 命名空间

    • Phalcon\Storage
  • 使用

    • Phalcon\Factory\AbstractFactory
    • Phalcon\Storage\Adapter\AdapterInterface
  • 继承

    AbstractFactory

  • 实现

该文件是Phalcon框架的一部分。

(c) Phalcon团队team@phalcon.io

有关完整的版权和许可信息,请查看随此源代码分发的LICENSE.txt文件。

属性

/**
 * @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;
返回可用的适配器

存储\异常

GitHub上的源码

  • 命名空间

    • Phalcon\Storage
  • 使用

  • 继承

    \Exception

  • 实现

Phalcon\Storage 异常

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

存储\序列化器\抽象序列化器Abstract

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

  • 继承

  • 实现

    • SerializerInterface

@属性 混合类型 $data @属性 布尔型 $isSuccess

属性

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

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

方法

public function __construct( mixed $data = null );
AbstractSerializer 构造函数。

public function __serialize(): array;
序列化数据

public function __unserialize( array $data ): void;
反序列化数据

public function getData(): mixed;

public function isSuccess(): bool;
返回true如果序列化/反序列化操作成功;false否则

public function setData( mixed $data ): void;

protected function isSerializable( mixed $data ): bool;
如果返回 true,则数据按原样返回

Storage\Serializer\Base64

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

    • InvalidArgumentException
  • 继承

    AbstractSerializer

  • 实现

该文件是Phalcon框架的一部分。

(c) Phalcon团队team@phalcon.io

有关完整的版权和许可信息,请查看随此源代码分发的LICENSE.txt文件。

方法

public function serialize(): string;
序列化数据

public function unserialize( mixed $data ): void;
反序列化数据

protected function phpBase64Decode( string $input, bool $strict = bool );
base64_decode 的包装器

Storage\Serializer\Igbinary

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

  • 继承

    AbstractSerializer

  • 实现

该文件是Phalcon框架的一部分。

(c) Phalcon团队team@phalcon.io

有关完整的版权和许可信息,请查看随此源代码分发的LICENSE.txt文件。

方法

public function serialize(): string;
序列化数据

public function unserialize( mixed $data ): void;
反序列化数据

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

protected function doUnserialize( mixed $value );
反序列化

protected function phpIgbinarySerialize( mixed $value ): string | null;
的包装器igbinary_serialize

Storage\Serializer\Json

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

    • InvalidArgumentException
    • JsonSerializable
    • Phalcon\Support\Helper\Json\Decode
    • Phalcon\Support\Helper\Json\Encode
  • 继承

    AbstractSerializer

  • 实现

该文件是Phalcon框架的一部分。

(c) Phalcon团队team@phalcon.io

有关完整的版权和许可信息,请查看随此源代码分发的LICENSE.txt文件。

属性

/**
 * @var Decode
 */
private $decode;

/**
 * @var Encode
 */
private $encode;

方法

public function __construct( mixed $data = null );
AbstractSerializer 构造函数。

public function serialize(): mixed;
序列化数据

public function unserialize( mixed $data ): void;
反序列化数据

Storage\Serializer\MemcachedIgbinary

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

  • 继承

    None

  • 实现

使用内置的 Memcached 'igbinary' 序列化器的序列化器

Storage\Serializer\MemcachedJson

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

  • 继承

    None

  • 实现

使用内置的 Memcached 'json' 序列化器的序列化器

Storage\Serializer\MemcachedPhp

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

  • 继承

    None

  • 实现

使用内置的 Memcached 'php' 序列化器的序列化器

Storage\Serializer\Msgpack

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

  • 继承

    Igbinary

  • 实现

该文件是Phalcon框架的一部分。

(c) Phalcon团队team@phalcon.io

有关完整的版权和许可信息,请查看随此源代码分发的LICENSE.txt文件。

方法

protected function doSerialize( mixed $value ): string;
序列化数据

protected function doUnserialize( mixed $value );

Storage\Serializer\None

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

  • 继承

    AbstractSerializer

  • 实现

该文件是Phalcon框架的一部分。

(c) Phalcon团队team@phalcon.io

有关完整的版权和许可信息,请查看随此源代码分发的LICENSE.txt文件。

方法

public function serialize(): mixed;
序列化数据

public function unserialize( mixed $data ): void;
反序列化数据

Storage\Serializer\Php

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

    • InvalidArgumentException
  • 继承

    AbstractSerializer

  • 实现

该文件是Phalcon框架的一部分。

(c) Phalcon团队team@phalcon.io

有关完整的版权和许可信息,请查看随此源代码分发的LICENSE.txt文件。

方法

public function serialize(): string;
序列化数据

public function unserialize( mixed $data ): void;
反序列化数据

Storage\Serializer\RedisIgbinary

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

  • 继承

    None

  • 实现

使用内置的 Redis 'igbinary' 序列化器的序列化器

Storage\Serializer\RedisJson

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

  • 继承

    None

  • 实现

使用内置的 Redis 'json' 序列化器的序列化器

Storage\Serializer\RedisMsgpack

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

  • 继承

    None

  • 实现

使用内置的 Redis 'msgpack' 序列化器的序列化器

Storage\Serializer\RedisNone

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

  • 继承

    None

  • 实现

使用内置的 Redis 'none' 序列化器的序列化器

Storage\Serializer\RedisPhp

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

  • 继承

    None

  • 实现

使用内置的 Redis 'php' 序列化器的序列化器

Storage\Serializer\SerializerInterfaceInterface

GitHub上的源码

  • 命名空间

    • Phalcon\Storage\Serializer
  • 使用

    • Serializable
  • 继承

    Serializable

  • 实现

该文件是Phalcon框架的一部分。

(c) Phalcon团队team@phalcon.io

有关完整的版权和许可信息,请查看随此源代码分发的LICENSE.txt文件。

方法

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

Storage\SerializerFactory

GitHub上的源码

  • 命名空间

    • Phalcon\Storage
  • 使用

    • Phalcon\Factory\AbstractFactory
    • Phalcon\Storage\Serializer\SerializerInterface
  • 继承

    AbstractFactory

  • 实现

该文件是Phalcon框架的一部分。

(c) Phalcon团队team@phalcon.io

有关完整的版权和许可信息,请查看随此源代码分发的LICENSE.txt文件。

方法

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

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

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

无噪 Logo
无噪文档
25 年 6 月翻译
版本号 5.9
文档源↗