why object refcount key return alway value is 1??how do not 1?
THANK MUCH!
Comment From: oranagra
One example would be to set a key to an integer value (e.g "6"), after setting eviction policy to noeviction
Comment From: startjava
Thank you very much, but redis seviction default value is noeviction, I don't want to change the redis.conf eviction policy, here is my test, I understand that abc is referenced by 3 keys, But the result of printing is 1, why not 3, thank you very much!
127.0.0.1:7777> flushall OK 127.0.0.1:7777> set a abc OK 127.0.0.1:7777> set b abc OK 127.0.0.1:7777> set c abc OK 127.0.0.1:7777> object refcount a 1 127.0.0.1:7777> object refcount b 1 127.0.0.1:7777> object refcount c 1 127.0.0.1:7777>
Comment From: oranagra
redis doesn't go out of its way to find duplicate values.. I think in current version, this will only work with small integer values.
Comment From: startjava
thank you ! but ,what code demo can return not 1 ? use object refcount command ? thank you !
Comment From: oranagra
Re-reading your previous post, maybe there's a misunderstanding about the purpose of this command. It doesn't intend to help users find duplicate values.. It's just debug command that looks into redis internals. IIUC In your example, if you'll change "abc" to "6", it should work..
Comment From: startjava
thank you! 127.0.0.1:7777> flushall OK 127.0.0.1:7777> set a abc OK 127.0.0.1:7777> set b abc OK 127.0.0.1:7777> set c abc OK 127.0.0.1:7777> object refcount a 1 127.0.0.1:7777> object refcount b 1 127.0.0.1:7777> object refcount c 1 127.0.0.1:7777>
I mean 1 "abc" is referenced by 3 keys, object refcount key value should print 3, not to calculate the number of duplicate "abc". but it print 1, this is my question thank you!
Comment From: oranagra
No. It shouldn't. Redis doesn't look for duplicate values! This command is somewhat a debug command that helps a developer look into redis internals. It doesn't aim to help you find duplicate values.
If you'll 6 instead of abc you'll get refcount of 3 (only if there's no eviction configured)
Comment From: startjava
thank you post! bottom my test : 127.0.0.1:7777> flushdb OK 127.0.0.1:7777> set a abc OK 127.0.0.1:7777> set a 6 OK 127.0.0.1:7777> object refcount a 2147483647 127.0.0.1:7777> flushdb OK 127.0.0.1:7777> set a "abc" OK 127.0.0.1:7777> set a "b" OK 127.0.0.1:7777> object refcount a 1 127.0.0.1:7777>
alway return value 1 and 2147483647,,but i don't know why this. or I don't even know what refcount means.
Comment From: startjava
@oranagra I now want to see how to do not return 1 or 2147483647, I think even if this command is for redis developers, in debugging will get the returnvalue is not 1 and 2147483647. Thank you very much.
Comment From: oranagra
@startjava i think that in current version these are the only two possibilities. i.e. shared small integers now have refcount of -1 (2147483647) indicating their shared. bottom line, don't use this command.
Comment From: antirez
I guess this discussion is concluded, thanks @oranagra for replying.
Comment From: Alireza17224
127.0.0.1:6379> set hello 1
OK
127.0.0.1:6379> set hello1 "Test"
OK
127.0.0.1:6379> object refcount hello1
(integer) 1
127.0.0.1:6379> object refcount hello1
(integer) 1
127.0.0.1:6379> object refcount hello
(integer) 2147483647
127.0.0.1:6379>
That would be like this ....