For example, I want to insert data into library No. 1 instead of the default library No. 0
I know that in the command line, use select 1 and then sadd xxx yyy,
But how do I write the code in php?
For example, I want to insert data into library No. 1 instead of the default library No. 0
I know that in the command line, use select 1 and then sadd xxx yyy,
But how do I write the code in php?
<code><?php $redis = new Redis(); $redis->connect('127.0.0.1'); $redis->select('1'); $redis->set('test',time()); echo $redis->get('test'); $redis->sAdd('s', 5); $redis->sAdd('s', 4); $redis->sAdd('s', 2); $redis->sAdd('s', 1); $redis->sAdd('s', 3); var_dump($redis->sort('s')); // 1,2,3,4,5</code>
PhpRedis - a redis extension written in C, fast, slightly troublesome to install
predis - a redis extension written in PHP. It is not as fast as PhpRedis, but it is more convenient to use it directly with composer
Both the above two libraries can do what you want.