sopheos / pebble_cache
缓存库
1.0.1
2024-09-04 08:12 UTC
Requires
- php: >=8.1.0
- psr/simple-cache: ^3.0
Requires (Dev)
- phpunit/phpunit: ^9.5
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()重置存储。