Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nosql 插入带有计数的日志_Nosql_Redis - Fatal编程技术网

Nosql 插入带有计数的日志

Nosql 插入带有计数的日志,nosql,redis,Nosql,Redis,在我工作的网站上,有一个搜索API。我想用Redis记录所有活动,但我不知道如何将这些数据存储到Redis中。应该有搜索查询和计数,可以按计数排序以查看搜索最多的查询。如果您能告诉我正确的方法,我将不胜感激。使用排序集 redis 127.0.0.1:6379> ZINCRBY searches 1 foo "1" redis 127.0.0.1:6379> ZINCRBY searches 1 bar "1" redis 127.0.0.1:6379> ZINCRBY sea

在我工作的网站上,有一个搜索API。我想用Redis记录所有活动,但我不知道如何将这些数据存储到Redis中。应该有搜索查询和计数,可以按计数排序以查看搜索最多的查询。如果您能告诉我正确的方法,我将不胜感激。

使用排序集

redis 127.0.0.1:6379> ZINCRBY searches 1 foo
"1"
redis 127.0.0.1:6379> ZINCRBY searches 1 bar
"1"
redis 127.0.0.1:6379> ZINCRBY searches 1 baz
"1"
redis 127.0.0.1:6379> ZINCRBY searches 1 foo
"2"
redis 127.0.0.1:6379> ZINCRBY searches 1 foo
"3"
redis 127.0.0.1:6379> ZINCRBY searches 1 bar
"2"
redis 127.0.0.1:6379> ZREVRANGE searches 0 -1 WITHSCORES
1) "foo"
2) "3"
3) "bar"
4) "2"
5) "baz"
6) "1"
使用排序集

redis 127.0.0.1:6379> ZINCRBY searches 1 foo
"1"
redis 127.0.0.1:6379> ZINCRBY searches 1 bar
"1"
redis 127.0.0.1:6379> ZINCRBY searches 1 baz
"1"
redis 127.0.0.1:6379> ZINCRBY searches 1 foo
"2"
redis 127.0.0.1:6379> ZINCRBY searches 1 foo
"3"
redis 127.0.0.1:6379> ZINCRBY searches 1 bar
"2"
redis 127.0.0.1:6379> ZREVRANGE searches 0 -1 WITHSCORES
1) "foo"
2) "3"
3) "bar"
4) "2"
5) "baz"
6) "1"
你经历了什么?使用
SortedSet
s是一项相当简单的任务。您是通过了还是?使用
SortedSet
s是一项相当简单的任务。