naroga/redis-cache

实现 PSR-16 (简单缓存) 的 Redis 驱动器

1.2 2021-01-25 13:15 UTC

This package is auto-updated.

Last update: 2024-08-25 20:46:27 UTC


README

Build status Coverage Status

这是一个简单的 Redis 驱动器,它实现了与 PHP 5.3.3+ 兼容的 PSR-16。

安装

使用 composer 安装

$ composer require naroga/redis-cache

就这么多。

naroga/redis-cache 遵循 SemVer

用法

naroga/redis-cache 应与 predis/predis 客户端一起构造。

您可以在Predis 的文档中找到更多信息

<?php

require_once "vendor/autoload.php";

use Naroga\RedisCache\Redis;
use Predis\Client;

$config = array(
    'scheme' => 'tcp',
    'host' => 'localhost',
    'port' => 6379
);

$redis = new Redis(new Client($config));

if (!$redis->has('myKey')) {
    $redis->set('myKey', 'myValue', 1800); //Just call any PSR-16 methods here.
}

许可

此库根据 MIT 许可证发布。有关更多信息,请参阅 LICENSE.md