在Redis中存储整数和字符串的区别 [英] Difference between storing Integers and Strings in Redis

查看:108
本文介绍了在Redis中存储整数和字符串的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两个命令有什么区别吗?

LPUSH myset 123LPUSH myset "123"

我想存储大约 500 万个整数,而且我想以最有效的方式存储.

解决方案

不,没有区别;两者都存储为字符串.来自 redis.io:

<块引用>

Redis 列表只是字符串列表,按插入顺序排序.

根据您的使用情况,您可能需要考虑使用集合,而不是列表.>

Any difference between these two commands?

LPUSH myset 123
LPUSH myset "123"

I want to store about 5 million integers and I want to do it in the most efficient way.

解决方案

No, there is no difference; both are stored as strings. From redis.io:

Redis Lists are simply lists of strings, sorted by insertion order.

Depending on your usage, you may want to consider using a set, rather than a list.

这篇关于在Redis中存储整数和字符串的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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