草庐IT

redis-test

全部标签

redis - 使用 RedisTemplate 设置一个值但从终端 Redis-CLI 获取 Nil

1.使用Springdataredis库将键name设置为alex。@TestpublicvoidtestOne()throwsException{redisTemplate.opsForValue().set("name","alex");}2.尝试使用redis-cli从终端获取名称,但得到的是Nil127.0.0.1:6379>getname(nil)3.然而alex可以像这样检索Objecthello=redisTemplate.opsForValue().get("name");System.out.println(hello);-----alex谁能解释一下,谢谢!

redis - 将关闭的 Redis 实例重新连接回集群

给定一个有六个节点(3M/3S)的redis集群,端口7000-7005上有主节点,端口7000-7002上有主节点,其余节点上有从节点,主节点7000关闭,因此节点7003成为新的主节点:$redis-cli-p7003clusternodes2a23385e94f8a27e54ac3b89ed3cabe394826111127.0.0.1:7004slave1108ef4cf01ace085b6d0f8fd5ce5021db86bdc7014526489643585connected5799de96ff71e9e49fd58691ce4b42c07d2a0ede127.0.0.1:

redis - 将关闭的 Redis 实例重新连接回集群

给定一个有六个节点(3M/3S)的redis集群,端口7000-7005上有主节点,端口7000-7002上有主节点,其余节点上有从节点,主节点7000关闭,因此节点7003成为新的主节点:$redis-cli-p7003clusternodes2a23385e94f8a27e54ac3b89ed3cabe394826111127.0.0.1:7004slave1108ef4cf01ace085b6d0f8fd5ce5021db86bdc7014526489643585connected5799de96ff71e9e49fd58691ce4b42c07d2a0ede127.0.0.1:

django - 是否可以在 session 后端为redis的nginx,uwsgi和django的多个服务器上部署应用程序?如何?

经过几天的搜索,我找到了nginxloadbanlancing似乎是解决方案,但我不确定。背景我有一个django应用程序mydomain在服务器A(外部ip120.25.x.200)上运行uwsgi和nginx。它的nginx.conf和uwsgi.ini是here.我将redis2.8用于缓存session:#/apps/mydomain/proj/settings.pyCACHES={"default":{"BACKEND":"django_redis.cache.RedisCache","LOCATION":"redis://127.0.0.1:6379/1","OPTIONS

django - 是否可以在 session 后端为redis的nginx,uwsgi和django的多个服务器上部署应用程序?如何?

经过几天的搜索,我找到了nginxloadbanlancing似乎是解决方案,但我不确定。背景我有一个django应用程序mydomain在服务器A(外部ip120.25.x.200)上运行uwsgi和nginx。它的nginx.conf和uwsgi.ini是here.我将redis2.8用于缓存session:#/apps/mydomain/proj/settings.pyCACHES={"default":{"BACKEND":"django_redis.cache.RedisCache","LOCATION":"redis://127.0.0.1:6379/1","OPTIONS

c# - 从代码创建 Azure Redis 缓存

我想从我的C#代码创建新的azureredis缓存。我发现powershell命令可以做到这一点,但我不想从代码中运行powershell。您知道是否有其他方法可以做到这一点? 最佳答案 有一个Microsoft.Azure.Management.Redisnugetpackage可用于管理azureredis缓存。您应该能够在C#代码中使用此nuget包。浏览powershellcodeongithub,看起来azurepowershellrediscommandlet在幕后引用了Microsoft.Azure.Managemen

c# - 从代码创建 Azure Redis 缓存

我想从我的C#代码创建新的azureredis缓存。我发现powershell命令可以做到这一点,但我不想从代码中运行powershell。您知道是否有其他方法可以做到这一点? 最佳答案 有一个Microsoft.Azure.Management.Redisnugetpackage可用于管理azureredis缓存。您应该能够在C#代码中使用此nuget包。浏览powershellcodeongithub,看起来azurepowershellrediscommandlet在幕后引用了Microsoft.Azure.Managemen

ruby - Rails Redis 将计数器重置为 0

我想在Rails4应用程序中将REDIS计数器的值重置为0。我使用hincrby来递增计数器$redis.hincrby("user:likes","key",1)我无法使用hdelhttp://redis.io/commands/hdel删除key因为我需要经常拿到key。GETSET是原子的,可以完成这项工作http://redis.io/commands/getset,如示例所示GETSETmycounter"0"但是因为我使用哈希,所以我需要使用HSEThttp://redis.io/commands/hset$redis.hset("user:likes","key","0"

ruby - Rails Redis 将计数器重置为 0

我想在Rails4应用程序中将REDIS计数器的值重置为0。我使用hincrby来递增计数器$redis.hincrby("user:likes","key",1)我无法使用hdelhttp://redis.io/commands/hdel删除key因为我需要经常拿到key。GETSET是原子的,可以完成这项工作http://redis.io/commands/getset,如示例所示GETSETmycounter"0"但是因为我使用哈希,所以我需要使用HSEThttp://redis.io/commands/hset$redis.hset("user:likes","key","0"

redis - 将队列数据移动到另一个队列的头部

我想将一个队列清空到另一个队列中。我假设RPOPLPUSH将是适合我的工具,运行它直到队列耗尽。我想在一个原子步骤中执行此操作,所以我认为Lua脚本将是适合我的工具。很遗憾,我编写的脚本无法运行。相反,它看起来陷入无限循环并在超时后触发BUSY错误。这是代码:localxifKEYS[1]==KEYS[2]thenreturnendrepeatx=redis.call('rpoplpush',KEYS[1],KEYS[2])untilnotx这是我用来执行它的Python客户端代码:script="""...samescriptasabove..."""redis.eval(scrip