有没有办法在整个应用程序中使用一个 Predis 客户端连接,但只为 session key 添加前缀?
Predis 库只允许通过设置选项参数 when instantiating a client object 来定义键前缀:
$sessionClient = new Predis\Client($config, array('prefix' => 'session-'));
我在一个 Redis 实例中存储的不仅仅是 session 。因此,要存储不带前缀的其他值,我认为这会起作用:
$client = new Predis\Client($config);
但是键仍然有前缀。我假设 Predis 正在跨客户端实例共享连接和选项。那么一个前缀怎么能只是 session key 呢?
最佳答案
找到 a related issue on Github作者回复说不支持。
Predis\Session\SessionHandler
accepts a client instance only for the sake of injection, but you shouldn't really reuse that client for anything else... Obviously, for very specific scenarios nothing stops you from writing your own session handler.
关于php - 仅前缀 redis session key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44308809/