I use command like this: sscan "d8ebe8b1-0e13-4560-87f9-efbcadfe746d" 0
and error: WRONGTYPE Operation against a key holding the wrong kind of value.
"-" is illegal character in redis? How to solve the above problem?
Comment From: badboy
It's as Redis told you: You're trying to execute the SSCAN command against a key holding a type that is not a set. Find out what TYPE that key is and use the correct command. Redis can handle all characters in keys.
Keep in mind that this issue tracker should be used for bugs or improvements to the Redis server. For questions like yours please ask on /r/redis, the mailing list or ask in the irc channel #redis on freenode.
Comment From: itamarhaber
No, key names are binary safe and you can use any character in them.
The error tells you that the key's type doesn't match the one that the operation expects. Since you're doing SSCAN, that means that your key isn't a Set. Use TYPE to find out that key's type.
Comment From: itamarhaber
@badboy lol, you're faster and better (hyperlinks, FAQ signature) - O(rz)
Comment From: sisabana
Many thanks!
But why I use command like this: SSCAN "d8ebe8b1_0e13_4560_87f9_efbcadfe746d" 0 My key type is string Is succeed!
ps:I have already ask on /r/redis
Comment From: itamarhaber
Understood, thanks for insisting :)
The pattern that SCAN accepts has some special characters that you need to escape by prepending '\'. So, try:
SSCAN "d8ebe8b1-0e13-4560-87f9-efbcadfe746d" 0
As for why SSCAN succeeds on a string... I can't imagine.
On Thu, Nov 12, 2015 at 1:09 PM, sisabana notifications@github.com wrote:
Many thanks!
But why I use command like this: SSCAN "d8ebe8b1_0e13_4560_87f9_efbcadfe746d" 0 My key type is string Is succeed!
ps:I have already ask on /r/redis
— Reply to this email directly or view it on GitHub https://github.com/antirez/redis/issues/2864#issuecomment-156075931.
Itamar Haber | Chief Developer Advocate & Senior Solution Architect Redis Watch Newsletter http://redislabs.com/redis-watch-archive | Curator and Janitor _Redis http://www.redislabs.com/_Labs http://www.redislabs.com/ | ~ of Redis
Mobile: +1 (415) 688 2443 Office: +1 (650) 461 4652 Mobile (IL): +972 (54) 567 9692 Office (IL): +972 (3) 720 8515 Ext. 123 Email: itamar@redislabs.com Twitter: @itamarhaber https://twitter.com/itamarhaber Skype: itamar.haber
Blog http://redislabs.com/blog/ | Twitter https://twitter.com/redislabs | LinkedIn https://www.linkedin.com/company/redis-labs-inc
https://www.redislabs.com/company/redis-labs-careers
Comment From: erikdubbelboer
@itamarhaber he is using SSCAN which has signature SSCAN key cursor [MATCH pattern] [COUNT count] so your escaping makes no sense at all as he isn't using any pattern.
@sisabana I'm pretty sure your d8ebe8b1_0e13_4560_87f9_efbcadfe746d key is not a string but probably non-existent:
$ redis-cli
127.0.0.1:6379> sadd d8ebe8b1-0e13-4560-87f9-efbcadfe746d a b c d e f
(integer) 6
127.0.0.1:6379> sscan "d8ebe8b1-0e13-4560-87f9-efbcadfe746d" 0
1) "0"
2) 1) "a"
2) "d"
3) "b"
4) "f"
5) "c"
6) "e"
127.0.0.1:6379> set d8ebe8b1-0e13-4560-87f9-efbcadfe746d test
OK
127.0.0.1:6379> sscan "d8ebe8b1-0e13-4560-87f9-efbcadfe746d" 0
(error) WRONGTYPE Operation against a key holding the wrong kind of value
127.0.0.1:6379> del d8ebe8b1-0e13-4560-87f9-efbcadfe746d
(integer) 1
127.0.0.1:6379> sscan "d8ebe8b1-0e13-4560-87f9-efbcadfe746d" 0
1) "0"
2) (empty list or set)
Comment From: manoharreddyporeddy
Found a repro & solution:
An example: When the key is "string", but starts with a number, like "336931--999999", then it fails with this error. When we prepend above with character (like 'a'), to make it "a336931--999999", then it passes.
Hope that helps.
Comment From: kiakaku
Thanks alot With one milion entries From 74398280 bytes, 70 MB to 14335352 bytes, 13 MB
Comment From: erikdubbelboer
@antirez why is this issue still open? :)
Comment From: shosain
I had to update my all key character to lowercase.
- public const string TokenCacheKey = "Token";
+ //Each character in Key has to be in lower cache,
+ //otherwise Get/SetStringAsync will thorugh "WRONGTYPE Operation against a key holding the wrong kind of value"
+ //- it's a Radis bug:
+ public const string TokenCacheKey = "token";
Comment From: itamarhaber
Closing as a non-issue - please feel free to reopen or create a new issue if needed.