codecamp

Redis 批量执行操作

使用telnet也可以连接redis-server。并且在脚本中使用nc命令进行redis操作也是很有效的:

gnuhpc@gnuhpc:~$ (echo -en "ping\r\nset key abc\r\nget key\r\n";sleep 1) | nc 127.0.0.1 6379
+PONG
+OK
$3
abc

另一个方式是使用pipeline:

在一个脚本中批量执行多个写入操作:
先把插入操作放入操作文本insert.dat:
set a b
set 1 2
set h w
set f u
然后执行命令:cat insert.bat | ./redis-cli --pipe,或者如下脚本:
#!/bin/sh
host=$1
port=$;
password=$3
cat insert.dat | ./redis-cli -h $host -p $port -a $password --pipe


Redis 查看和修改配置
Redis 选择数据库
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

Redis 数据操作

Redis安全问题

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }