dealnews/caching

Caching PHP 库(Memcache、Redis 等)

2.3.0 2024-06-11 23:18 UTC

This package is auto-updated.

Last update: 2024-09-11 23:48:57 UTC


README

这个库提供了一个标准的缓存接口,并为实现了该接口的 Memcached 和 Redis 提供了类。我们创建这个库是因为我们在不同的缓存服务之间迁移,并希望有一个统一的接口。

待办事项

  • 添加 PSR-6 和/或 PSR-16 兼容的类

示例

; config.ini in your app base directory

[caching.memcache]
caching.memcache.app.servers = 10.0.0.1:11211,10.0.0.2:11211

[caching.redis]
caching.redis.sessions.servers = 10.0.0.3,10.0.0.4
; supports redis auth and other options that the
; predis/predis library supports such as sentinel replication
caching.redis.sessions.username = someuser
caching.redis.sessions.password = XXXXXXXX
<?php

$cache = \DealNews\Caching\Cache::factory("app");
$value = $cache->get("somekey");
$cache->set("somekey", 1);
$cache->delete("somekey");