入队操作
复制代码 代码如下:
<?php
$redis = new Redis();
$redis->connect('127.0.0.1',6379);
while(True){
try{
$value = 'value_'.date('Y-m-d H:i:s');
$redis->LPUSH('key1',$value);
sleep(rand()%3);
echo $value."/n";
}catch(Exception $e){
echo $e->getMessage()."/n";
}
}
?>
复制代码 代码如下:
<?php
$redis = new Redis();
$redis->pconnect('127.0.0.1',6379);
while(True){
try{
echo $redis->LPOP('key1')."/n";
}catch(Exception $e){
echo $e->getMessage()."/n";
}
sleep(rand()%3);
}?>
复制代码 代码如下:
<?php
$redis = getRedisInstance();//从Redis服务器拿到redis实例
$redis->connect('Redis服务器IP', 6379);
while (true) {
$redis->lPush('list1', 'A_'.date('Y-m-d H:i:s'));
sleep(rand()%3);
}
?>
复制代码 代码如下:
<?php
$redis = getRedisInstance();//从Redis服务器拿到redis实例
$redis->pconnect('Redis服务器IP', 6379);
while(true) {
try {
var_export( $redis->blPop('list1', 10) );
} catch(Exception $e) {
//echo $e;
}
}
复制代码 代码如下:
#!/usr/bin/env python
import time
from redis import Redis
redis = Redis(host='127.0.0.1', port=6379)
while True:
now = time.strftime("%Y/%m/%d %H:%M:%S")
redis.lpush('test_queue', now)
time.sleep(1)
复制代码 代码如下:
#!/usr/bin/env python
import sys
from redis import Redis
redis = Redis(host='127.0.0.1', port=6379)
while True:
res = redis.rpop('test_queue')
if res == None:
pass
else:
print str(res)
新闻热点
疑难解答