Redis Data Structure-keys

Source: Internet
Author: User


 

This is the keys list of the redis official documentation.

 

(1) set key value -- set a key to a value

(2) Get key -- get the set value

(3) DEL key -- delete the set key

(4) expire key seconds -- set the time when the key value exists

(5) expireat key timestamp -- more advanced key value retention time.

(6) Keys pattern -- view the number of key values (Keys * can return all keys)

(7) Move key dB -- move a key value to another database (you can use select dB to select a database)

(8) object --

The object command allows to inspect the internals of redis objects associated with keys.It is useful for debugging or to understand if your keys are using the specially encoded data types to save space. your application may also use the information reported by the object command to implement application level key eviction policies ies when using redis as a cache.

The object command supports multiple sub commands:

  • OBJECT REFCOUNT <key>Returns the number of references of the value associated with the specified key. This command is mainly useful for debugging.
  • OBJECT ENCODING <key>Returns the kind of internal representation used in order to store the value associated with a key.
  • OBJECT IDLETIME <key>Returns the number of seconds since the object stored at the specified key is idle (not requested by read or write operations ). while the value is returned in seconds the actual resolution of this timer is 10 seconds, but may vary in future implementations.

Objects can be encoded in different ways:

  • Strings can be encodedraw(Normal string encoding) orint(Strings representing integers in a 64 bit signed interval are encoded in this way in order to save space ).
  • Lists can be encodedziplistOrlinkedlist.ziplistIs the special representation that is used to save space for small lists.
  • Sets can be encodedintsetOrhashtable.intsetIs a special encoding used for small sets composed solely of integers.
  • Hashes can be encodedzipmapOrhashtable.zipmapIs a special encoding used for small hashes.
  • Sorted sets can be encodedziplistOrskiplistFormat. As for the list type small sorted sets can be specially encoded usingziplist, WhileskiplistEncoding is the one that works with sorted sets of any size.

All the specially encoded types are automatically converted to the general type once you perform an operation that makes it impossible for redis to retain the space saving encoding.

Return Value

Different return values are used for different subcommands.

  • SubcommandsrefcountAndidletimeReturn integers.
  • SubcommandencodingReturns a bulk reply.

If the object you try to inspect is missing, a null bulk reply is returned.

Examples
redis> lpush mylist "Hello World"
(integer) 4
redis> object refcount mylist
(integer) 1
redis> object encoding mylist
"ziplist"
redis> object idletime mylist
(integer) 10

In the following example you can see how the encoding changes once redis is no longer able to use the space saving encoding.

redis> set foo 1000
OK
redis> object encoding foo
"int"
redis> append foo bar
(integer) 7
redis> get foo
"1000bar"
redis> object encoding foo
"raw"

(9) pexpire key milliseconds -- set the key value to be saved in milliseconds

(10) pexpireat key milliseconds -- timestap

(11) TTL key -- how many seconds does the set key value have to be saved!

(12) Rename key newkey -- rename a new key value

(13) renamenx key newkey -- rename a new key value only when the key does not exist.

(14) Sort key [by pattern] [limit offset count] [get pattern [get pattern...] [ASC | DESC] [Alpha] [store destination]

 

 

Redis Data Structure-keys

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.