CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 商业解决方案
  • 周边商品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题(Github)
    • 烘焙坊
    • 特色资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 新闻通讯
    • 领英
    • YouTube
    • 脸书
    • 推特
    • Mastodon
    • 帮助与支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

命名空间

  • 全局
  • Cake
    • Cache
      • Engine
      • Exception
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

类 ApcuEngine

用于缓存的 APCu 存储引擎

命名空间: Cake\Cache\Engine

常量

  • 字符串
    CHECK_KEY ¶
    'key'
  • 字符串
    CHECK_VALUE ¶
    'value'

属性摘要

  • $_compiledGroupNames protected
    list<string>

    包含已编译的组名称(以全局配置前缀为前缀)

  • $_config protected
    array<string, mixed>

    运行时配置

  • $_configInitialized protected
    bool

    配置属性是否已使用默认值进行配置

  • $_defaultConfig protected
    array<string, mixed>

    默认缓存配置在大多数缓存适配器中被覆盖。这些是所有适配器通用的键。如果被覆盖,则不使用此属性。

  • $_groupPrefix protected
    字符串

    包含已编译的字符串,其中所有组前缀都将被附加到此缓存引擎中的每个键之前

方法摘要

  • _configDelete() protected

    删除单个配置键。

  • _configRead() protected

    读取配置键。

  • _configWrite() protected

    写入配置键。

  • _key() protected

    为缓存后端使用生成键。

  • add() public

    如果键不存在,则将键的数据写入缓存。如果已经存在,则失败并返回 false。

  • clear() public

    从缓存中删除所有键。这将清除使用 APC 的每个缓存配置。

  • clearGroup() public

    递增组值以模拟删除组下的所有键,旧值将保留在存储中直到它们过期。

  • configShallow() public

    将提供的配置与现有配置合并。与 config() 不同,后者对嵌套键进行递归合并,此方法进行简单合并。

  • decrement() public

    减少缓存的整数键的值

  • delete() public

    从缓存中删除键

  • deleteMultiple() public

    删除多个缓存项作为列表

  • duration() protected

    将 TTL 值的各种表达式转换为以秒为单位的持续时间

  • ensureValidKey() protected

    确保给定缓存键的有效性。

  • ensureValidType() protected

    确保参数类型和缓存键的有效性。

  • get() public

    从缓存中读取键

  • getConfig() public

    返回配置。

  • getConfigOrFail() public

    返回此特定键的配置。

  • getMultiple() public

    通过其唯一键获取多个缓存项。

  • groups() public

    返回每个配置组的 组值 如果未找到组初始值,则相应地初始化组。

  • has() public

    确定缓存中是否存在项。

  • increment() public

    增加缓存的整数键的值

  • init() public

    初始化缓存引擎

  • set() public

    将键的数据写入缓存

  • setConfig() public

    设置配置。

  • setMultiple() public

    在缓存中持久化一组键 => 值对,并带有一个可选的 TTL。

  • warning() protected

    如果在操作过程中遇到故障,并且将选项 warnOnWriteFailures 设置为 true,则缓存引擎可能会触发警告。

方法详细信息

_configDelete() ¶ protected

_configDelete(string $key): void

删除单个配置键。

参数
string $key

要删除的键。

返回
void
抛出
Cake\Core\Exception\CakeException
如果尝试覆盖现有配置

_configRead() ¶ protected

_configRead(string|null $key): mixed

读取配置键。

参数
string|null $key

要读取的键。

返回
混合

_configWrite() ¶ protected

_configWrite(array<string, mixed>|string $key, mixed $value, string|bool $merge = false): void

写入配置键。

参数
array<string, mixed>|string $key

要写入的键。

mixed $value

要写入的值。

string|bool $merge optional

True 表示递归合并,'shallow' 表示简单合并,false 表示覆盖,默认值为 false。

返回
void
抛出
Cake\Core\Exception\CakeException
如果尝试覆盖现有配置

_key() ¶ protected

_key(string $key): string

为缓存后端使用生成键。

如果请求的键有效,则应用组前缀值和引擎前缀。键中的空格将被替换。

参数
string $key

传递的键

返回
字符串
抛出
Cake\Cache\Exception\InvalidArgumentException
如果键的值无效。

add() ¶ public

add(string $key, mixed $value): bool

如果键不存在,则将键的数据写入缓存。如果已经存在,则失败并返回 false。

默认为非原子实现。子类应该优先使用原子实现。

参数
string $key

数据的标识符。

mixed $value

要缓存的数据。

返回
bool
链接
https://secure.php.net/manual/en/function.apcu-add.php

clear() ¶ public

clear(): bool

从缓存中删除所有键。这将清除使用 APC 的每个缓存配置。

返回
bool
链接
https://secure.php.net/manual/en/function.apcu-cache-info.php

https://secure.php.net/manual/en/function.apcu-delete.php

clearGroup() ¶ public

clearGroup(string $group): bool

递增组值以模拟删除组下的所有键,旧值将保留在存储中直到它们过期。

每个实现都需要决定是实际删除键,还是只是增加组生成值以达到相同的结果。

参数
string $group

要清除的组。

返回
bool
链接
https://secure.php.net/manual/en/function.apcu-inc.php

configShallow() ¶ public

configShallow(array<string, mixed>|string $key, mixed|null $value = null): $this

将提供的配置与现有配置合并。与 config() 不同,后者对嵌套键进行递归合并,此方法进行简单合并。

设置特定值

$this->configShallow('key', $value);

设置嵌套值

$this->configShallow('some.nested.key', $value);

同时更新多个配置设置

$this->configShallow(['one' => 'value', 'another' => 'value']);
参数
array<string, mixed>|string $key

要设置的键,或完整的配置数组。

mixed|null $value optional

要设置的值。

返回
$this

decrement() ¶ public

decrement(string $key, int $offset = 1): int|false

减少缓存的整数键的值

参数
string $key

数据的标识符

int $offset optional

要减去的数量

返回
int|false
链接
https://secure.php.net/manual/en/function.apcu-dec.php

delete() ¶ public

delete(string $key): bool

从缓存中删除键

参数
string $key

数据的标识符

返回
bool
链接
https://secure.php.net/manual/en/function.apcu-delete.php

deleteMultiple() ¶ public

deleteMultiple(iterable<string> $keys): bool

删除多个缓存项作为列表

这是一个尽力而为的尝试。如果删除项目会导致错误,则将忽略该错误,并且将尝试删除所有项目。

参数
iterable<string> $keys

要删除的基于字符串的键列表。

返回
bool
抛出
Cake\Cache\Exception\InvalidArgumentException
如果 $keys 不是数组也不是 Traversable,或者任何 $keys 都不是合法值。

duration() ¶ protected

duration(DateInterval|int|null $ttl): int

将 TTL 值的各种表达式转换为以秒为单位的持续时间

参数
DateInterval|int|null $ttl

此项目的 TTL 值。如果发送 null,将使用驱动程序的默认持续时间。

返回
int

ensureValidKey() ¶ protected

ensureValidKey(mixed $key): void

确保给定缓存键的有效性。

参数
混合 $key

要检查的键。

返回
void
抛出
Cake\Cache\Exception\InvalidArgumentException
当键无效时。

ensureValidType() ¶ 受保护的

ensureValidType(iterable $iterable, string $check = self::CHECK_VALUE): void

确保参数类型和缓存键的有效性。

参数
可迭代的 $iterable

要检查的可迭代对象。

字符串 $check 可选的

是否检查键或值。

返回
void
抛出
Cake\Cache\Exception\InvalidArgumentException

get() ¶ 公共的

get(string $key, mixed $default = null): mixed

从缓存中读取键

参数
string $key

数据的标识符

混合 $default 可选的

缓存未命中时的默认值。

返回
混合
链接
https://secure.php.net/manual/en/function.apcu-fetch.php

getConfig() ¶ 公共的

getConfig(string|null $key = null, mixed $default = null): mixed

返回配置。

用法

读取整个配置

$this->getConfig();

读取特定值

$this->getConfig('key');

读取嵌套值

$this->getConfig('some.nested.key');

使用默认值读取

$this->getConfig('some-key', 'default-value');
参数
字符串|空 $key 可选的

要获取的键,或整个配置的空。

混合 $default 可选的

键不存在时的返回值。

返回
混合

getConfigOrFail() ¶ 公共的

getConfigOrFail(string $key): mixed

返回此特定键的配置。

此键的配置值必须存在,不能为 null。

参数
string $key

要获取的键。

返回
混合
抛出
InvalidArgumentException

getMultiple() ¶ 公共的

getMultiple(iterable<string> $keys, mixed $default = null): iterable<string, mixed>

通过其唯一键获取多个缓存项。

参数
iterable<string> $keys

可以在单个操作中获取的键列表。

混合 $default 可选的

对不存在的键返回的默认值。

返回
iterable<string, mixed>
抛出
Cake\Cache\Exception\InvalidArgumentException
如果 $keys 不是数组也不是 Traversable,或者任何 $keys 都不是合法值。

groups() ¶ 公共的

groups(): list<string>

返回每个配置组的 组值 如果未找到组初始值,则相应地初始化组。

返回
list<string>
链接
https://secure.php.net/manual/en/function.apcu-fetch.php

https://secure.php.net/manual/en/function.apcu-store.php

has() ¶ 公共的

has(string $key): bool

确定缓存中是否存在项。

注意:建议仅将 has() 用于缓存预热目的,而不是在您的实时应用程序操作中用于 get/set,因为此方法容易出现竞争条件,您的 has() 会返回 true,而紧随其后,另一个脚本可能会将其删除,从而导致您的应用程序状态过时。

参数
string $key

缓存项键。

返回
bool
抛出
Cake\Cache\Exception\InvalidArgumentException
如果 $key 字符串不是合法值。

increment() ¶ 公共的

increment(string $key, int $offset = 1): int|false

增加缓存的整数键的值

参数
string $key

数据的标识符

int $offset optional

递增多少

返回
int|false
链接
https://secure.php.net/manual/en/function.apcu-inc.php

init() ¶ 公共的

init(array<string, mixed> $config = []): bool

初始化缓存引擎

由缓存前端自动调用

参数
数组<字符串, 混合> $config 可选的

引擎设置的数组

返回
bool

set() ¶ 公共的

set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool

将键的数据写入缓存

参数
string $key

数据的标识符

mixed $value

要缓存的数据

DateInterval|整数|空 $ttl 可选的

可选。此项的 TTL 值。如果未发送值且驱动程序支持 TTL,则库可能会为其设置默认值或让驱动程序处理该值。

返回
bool
链接
https://secure.php.net/manual/en/function.apcu-store.php

setConfig() ¶ 公共的

setConfig(array<string, mixed>|string $key, mixed|null $value = null, bool $merge = true): $this

设置配置。

用法

设置特定值

$this->setConfig('key', $value);

设置嵌套值

$this->setConfig('some.nested.key', $value);

同时更新多个配置设置

$this->setConfig(['one' => 'value', 'another' => 'value']);
参数
array<string, mixed>|string $key

要设置的键,或完整的配置数组。

mixed|null $value optional

要设置的值。

布尔 $merge 可选的

是否递归合并或覆盖现有配置,默认为 true。

返回
$this
抛出
Cake\Core\Exception\CakeException
尝试设置无效键时。

setMultiple() ¶ 公共的

setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool

在缓存中持久化一组键 => 值对,并带有一个可选的 TTL。

参数
可迭代的 $values

用于多重设置操作的键 => 值对列表。

DateInterval|整数|空 $ttl 可选的

可选。此项的 TTL 值。如果未发送值且驱动程序支持 TTL,则库可能会为其设置默认值或让驱动程序处理该值。

返回
bool
抛出
Cake\Cache\Exception\InvalidArgumentException
如果 $values 不是数组或 Traversable,或者 $values 中的任何一个都不是合法值。

warning() ¶ 受保护的

warning(string $message): void

如果在操作过程中遇到故障,并且将选项 warnOnWriteFailures 设置为 true,则缓存引擎可能会触发警告。

参数
字符串 $message

警告消息。

返回
void

属性详细信息

$_compiledGroupNames ¶ 受保护的

包含已编译的组名称(以全局配置前缀为前缀)

类型
list<string>

$_config ¶ 受保护的

运行时配置

类型
array<string, mixed>

$_configInitialized ¶ 受保护的

配置属性是否已使用默认值进行配置

类型
bool

$_defaultConfig ¶ 受保护的

默认缓存配置在大多数缓存适配器中被覆盖。这些是所有适配器通用的键。如果被覆盖,则不使用此属性。

  • 持续时间 指定此缓存配置中项的持续时间。
  • 组 与存储在此配置中的每个键关联的组或“标签”列表。便于从缓存中删除整个组。
  • 前缀 附加到所有条目的前缀。当您需要与另一个缓存配置或另一个应用程序共享键空间时很有用。
  • warnOnWriteFailures 一些引擎(如 ApcuEngine)可能会在写入失败时引发警告。
类型
array<string, mixed>

$_groupPrefix ¶ 受保护的

包含已编译的字符串,其中所有组前缀都将被附加到此缓存引擎中的每个键之前

类型
字符串
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与
  • 问题(Github)
  • 烘焙坊
  • 特色资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 新闻通讯
  • 领英
  • YouTube
  • 脸书
  • 推特
  • Mastodon
  • 帮助与支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成