Exemplo n.º 1
0
<?php

/**
 * Author: jellycheng <*****@*****.**>
 * Date: 2015/11/11
 * Desc: 
 */
header("Content-type: text/html; charset=utf-8");
require dirname(__DIR__) . '/vendor/autoload.php';
//设置用户信息
$userinfo = array('userid' => 123456, 'phone' => '13712345678', 'nickname' => '租888借');
$bool = \JellyRedis\Redis\Redis::set("user", "userinfo:123456", json_encode($userinfo));
//获取缓存用户组信息
$res = \JellyRedis\Redis\Redis::get("user", "userinfo:123456");
var_dump($res);
echo "<br>";
Exemplo n.º 2
0
<?php

/**
 * Author: jellycheng <*****@*****.**>
 * Date: 2015/11/11
 * Desc: 
 */
header("Content-type: text/html; charset=utf-8");
require __DIR__ . '/vendor/autoload.php';
//备注: 所有方法的第1个参数一定是业务组代号,如果业务组代号不存在或者其它参数错误,均返回空
$res = \JellyRedis\Redis\Redis::get();
//参数错误写法,但不会出现错误,返回空
echo "参数错误写法,但不会出现错误,返回空: ";
var_dump($res);
//一定是空
echo "<br>";
echo "传入不存在的组,也不会直接影响业务,结果一直返回空: ";
$res = \JellyRedis\Redis\Redis::set("group", "key1", "val1");
var_dump($res);
echo "<br>";
//获取不存在组的情况,一直返回空
echo "获取不存在组的情况,一直返回空: ";
$res = \JellyRedis\Redis\Redis::get("group", "key1");
var_dump($res);
echo "<br>";
//获取缓存用户组信息
$res = \JellyRedis\Redis\Redis::get("user", "userinfo:123456");
var_dump($res);
echo "<br>";
echo "dbsize: " . \JellyRedis\Redis\Redis::dbsize('user');
echo "<br>";
Exemplo n.º 3
0
<?php

/**
 * Author: jellycheng <*****@*****.**>
 * Date: 2015/11/11
 * Desc: 
 */
header("Content-type: text/html; charset=utf-8");
require dirname(__DIR__) . '/vendor/autoload.php';
//设置用户信息
$userinfo = array('userid' => 88, 'phone' => '13712345678', 'nickname' => '租八借');
$bool = \JellyRedis\Redis\Redis::set("user", "userinfo:" . $userinfo['userid'], json_encode($userinfo));
var_export($bool);
echo "<br>";
echo "aaz:user:userinfo:" . $userinfo['userid'] . "的有效期(-1表永久,-2key不存在,单位秒): " . \JellyRedis\Redis\Redis::ttl('user', 'userinfo:' . $userinfo['userid']);
echo "<br>";
echo "aaz:user:abc的有效期(-1表永久,-2key不存在,单位秒): " . \JellyRedis\Redis\Redis::ttl('user', 'abc');
echo "<br>";
$i = mt_rand(1000, 9999);
//设置有效期 EXPIRE key seconds
\JellyRedis\Redis\Redis::set('user', 'jelly' . $i, "jelly nickname");
\JellyRedis\Redis\Redis::EXPIRE('user', 'jelly' . $i, 90);
echo "jelly" . $i . "的有效期(-1表永久,-2key不存在,单位秒): " . \JellyRedis\Redis\Redis::ttl('user', 'jelly' . $i);
echo "<br>";
echo "dbsize: " . \JellyRedis\Redis\Redis::dbsize('user');
echo "<br>";
$obj = \JellyRedis\Redis\Redis::getInstance('user');
$keys = $obj->keys('*');
echo "<pre>user组服务器,所有key:";
var_export($keys);
Exemplo n.º 4
0
<?php

/**
 * Author: jellycheng <*****@*****.**>
 * Date: 2015/11/11
 * Desc: 
 */
header("Content-type: text/html; charset=utf-8");
require dirname(__DIR__) . '/vendor/autoload.php';
$res = \JellyRedis\Redis\Redis::set("pay", "key1", "val1");
var_dump($res);
$res = \JellyRedis\Redis\Redis::get("pay", "key1");
var_dump($res);
//val1
$res = \JellyRedis\Redis\Redis::set("auth", "key1", "你好auth db1");
var_dump($res);
$res = \JellyRedis\Redis\Redis::get("auth", "key1");
var_dump($res);