[英]StackExchange.Redis SetAdd(key, val) crashes with key = GUID
Very annoying crash with StackExchange.Redis
SetAdd(key, val)
. 很烦人的崩溃与StackExchange.Redis
SetAdd(key, val)
I want to set a set with the programs GUID as a key. 我想设置一个程序GUID作为键的集合。
I found (after 3 hours debugging) that SetAdd(key, val)
works with some GUID, but crashes with others: 我发现(调试3小时后) SetAdd(key, val)
与一些GUID一起工作,但与其他人崩溃:
string key = "02639d71-0935-35e8-9d1b-9dd1a2a34629";
const string val = "somevalue";
db.SetAdd(key, val); // <=== Works
key = "02639d71-0935-35e8-9d1b-9dd1a2a34627";
db.SetAdd(key, val); // <=== CRASH @@!!@!@!
The difference is the last character "9" vs "7" 不同的是最后一个字符“9”vs“7”
Doesn't SetAdd
work with the local GUID as a Key? SetAdd
不能使用本地GUID作为密钥吗?
Environment: C# .NET 4 Win 8.1 VS2013 环境:C#.NET 4 Win 8.1 VS2013
Crash message: 崩溃消息:
An unhandled exception of type 'StackExchange.Redis.RedisServerException' occurred in StackExchange.Redis.dll
Additional information: WRONGTYPE Operation against a key holding the wrong kind of value
The crash point in StackExchange.Redis
StackExchange.Redis
的崩溃点
... ...
I tested this Code in LINQPad. 我在LINQPad中测试了这段代码。 It crashes on the same place. 它在同一个地方崩溃了。 The first GUID works, the second doesn't. 第一个GUID有效,第二个没有。
It seams that the crash is not due to this is the starting app GUID. 它会导致崩溃不是由于这是启动应用程序GUID。
More test with different GUIDs. 使用不同的GUID进行更多测试。 Only that ending with '7' crashes. 只有以'7'结尾的那个崩溃。
key = "02639d71-0935-35e8-9d1b-9dd1a2a34622";
key = "02639d71-0935-35e8-9d1b-9dd1a2a34623";
key = "02639d71-0935-35e8-9d1b-9dd1a2a34624";
key = "02639d71-0935-35e8-9d1b-9dd1a2a34625";
key = "02639d71-0935-35e8-9d1b-9dd1a2a34626";
key = "02639d71-0935-35e8-9d1b-9dd1a2a34627"; // <= crashes
key = "02639d71-0935-35e8-9d1b-9dd1a2a34628";
key = "02639d71-0935-35e8-9d1b-9dd1a2a34629";
... ...
KeyExists
, StringIncrement
, StringSet
work well with key = my GUID. KeyExists
, StringIncrement
, StringSet
与key = my GUID配合良好。
Redis keys are opaque. Redis键是不透明的。 That message: 那条消息:
WRONGTYPE Operation against a key holding the wrong kind of value WRONGTYPE对一个持有错误值的键的操作
simply means that you have previously stored data in that key of a type that isn't a "set". 只是意味着您先前已将数据存储在非“set”类型的键中。 Try (in redis-cli): 尝试(在redis-cli中):
TYPE "02639d71-0935-35e8-9d1b-9dd1a2a34627"
which will tell you the data type of the existing data. 它将告诉您现有数据的数据类型。 You can only use SADD
if either the key does not exist, or if it exists and is a set . 如果密钥不存在,或者密钥存在且是集合 ,则只能使用SADD
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.