limingxinleo / x-redis
Redis Client for phpredis
Installs: 5 501
Dependents: 3
Suggesters: 0
Security: 0
Stars: 7
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
- ext-redis: >=3.0
Requires (Dev)
- phpunit/phpunit: >=4.8
This package is auto-updated.
Last update: 2024-12-17 19:53:07 UTC
README
安装
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