将结果传递给Redis中的另一个命令 [英] pass results to another command in redis

查看:89
本文介绍了将结果传递给Redis中的另一个命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Redis中是否可以将一个函数的返回值传递给另一个函数?当然,如果您使用的是语言包装器(如Ruby),这很简单-但是从CLI呢?

Is there a way to pass the return value of one function to another in Redis? Of course, if you're using a language wrapper (like Ruby), it's easy — but what about from the CLI?

例如像这样的bash样式

e.g. something like this, bash style

redis 127.0.0.1:6379> keys student* | mget

或类似的东西

redis 127.0.0.1:6379> mget(keys student*)

重点学生* 将返回键列表,但我不知道如何获取这些键的所有值。

keys student* will return a list of keys, but I've no idea how to fetch all the values for those keys.

想法?

推荐答案

在CLI中,您只需要让Shell完成其工作即可。

From the CLI, you just have to let the shell do its job.

./redis-cli --raw keys 'student:*' | awk '{printf "get %s\n", $1}' | ./redis-cli --raw

请注意,您不应该在应用程序中使用keys命令因为它的线性复杂性。

Please note you are not supposed to use the keys command in applications because of its linear complexity.

这篇关于将结果传递给Redis中的另一个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆