limingxinleo/x-redis

Redis Client for phpredis

1.0.4 2018-05-03 02:43 UTC

This package is auto-updated.

Last update: 2024-12-17 19:53:07 UTC


README

Build Status

安装

composer require limingxinleo/x-redis

使用

<?php
use Xin\Redis; 
$redis = Redis::getInstance();
$redis->set('key','val');
echo $redis->get('key'); // val

使用LuaCommand

<?php
use Xin\Redis\Commands;
use Xin\Redis; 

$command = new Commands\IncrByWithExpireTimeCommand($this->key, 5, 3600);
$redis = Redis::getInstance();
$res = $redis->evaluate($command->getScript(), $command->getArguments(), $command->getNumKeys());
echo $res; // 5
$time = $redis->ttl($this->key);
echo $time; // 3600

sleep(1);

$res = $redis->evaluate($command->getScript(), $command->getArguments(), $command->getNumKeys());
echo $res; // 10
$time = $redis->ttl($this->key);
echo $time; // 3599