sopheos/pebble_cache

1.0.1 2024-09-04 08:12 UTC

This package is auto-updated.

Last update: 2024-09-04 08:13:08 UTC


README

缓存系统。

CacheInterface

  • start(): static 启动服务
  • close(): static 停止服务
  • set(string $key, $value, int $expiration = 0): static 添加数据。
  • setMulti(array $items, int $expiration = 0): static 添加一组数据。
  • delete(string $key): static 删除数据。
  • get(string $key): mixed 获取数据
  • getMulti(array $keys): array 获取一组数据。
  • increment(string $key, int $expiration = 0, int $offset = 1): static : 增加值。 (如果不存在,则为 $offset.)
  • decrement(string $key, int $expiration = 0, int $offset = 1): static : 减少值。 (如果不存在,则为 - $offset.)

MemCache

  • 实现 CacheInterface
  • 连接到Memcached服务器。

MicroCache

  • 实现 CacheInterface
  • 仅在脚本执行期间保留缓存中的数据。
  • 方法过期无效。

SessionHandler

  • 实现 SessionHandlerInterface
  • 允许将会话存储在 CacheInterface 中。

RateLimit

防垃圾邮件,将尝试存储在 CacheInterface 中。

使用令牌桶原理:[https://en.wikipedia.org/wiki/Token_bucket](https://en.wikipedia.org/wiki/Token_bucket)

  • __construct(CacheInterface $cache, string $name, int $max, int $period) 创建一个 RateLimit
    • $name : 名称
    • $max : 初始存储
    • $period : 在部分重置存储之前的秒数
  • hit(int $use = 1): bool : 消耗 $use 个存储元素并检查存储是否仍然满。
  • stock(): int 获取当前存储。
  • purge() 重置存储。