Redis-key operation

Source: Internet
Author: User

SET
 
   
  
  1. set 1 jingya
    • Del
 
   
  
  1. del 1
Dump, it's not going to restore. RESTORE key TTL serialized-value

    • Exists
 
   
  
  1. exists 1
    • EXPIRE
 
   
  
  1. expire 1 10 // 10s后失效
  2. ttl 1 //只需观察1
    • Expireat
 
   
  
  1. expireat 2 1455886380 // 使用unix时间戳设置过期时间
    • KEYS
  
 
  1. KEYS * 匹配数据库中所有 key 。
  2. KEYS h?llo 匹配 hello , hallo 和 hxllo 等。 // ? 匹配 1个字符
  3. KEYS h*llo 匹配 hllo 和 heeeeello 等。 // 匹配0个或者多个
  4. KEYS h[ae]llo 匹配 hello 和 hallo ,但不匹配 hillo // 匹配任意一个
    • MIGRATE
 
   
  
  1. MIGRATE host port key destination-db timeout [COPY] [REPLACE]
 
   
  
  1. MIGRATE 127.0.0.1 7777 greeting 0 1000
Timeoutparameter specifies the current instance and the target instance to communicate in milliseconds . Maximum time interval. This means that the operation does not necessarily have to beTimeoutmilliseconds to complete, just that the data transfer time cannot exceed thisTimeoutnumber.
    • COPY : Does not remove the key on the source instance.
    • Replace: Replaces the key that already exists on the target instance.

    • MOVE

 
   
  
  1. move key db
if the current database (source database) and the given database (the target database) have the same name as the givenKey, orKeydoes not exist in the current database, thenMOVEwithout any effect.

    • OBJECT
No
    • Persist
    •    
           
          
      1. PERSIST key
removes the givenKeyTime to Live

Pexpire
 
   
  
  1. Pexpire key milliseconds
Pexpireat
 
   
  
  1. PEXPIREAT key milliseconds-timestamp
Pttl
 
   
  
  1. PTTL key
Randomkey
Randomly returns a key
Rename
 
   
  
  1. Rename key newkey
This is a forced rename Renamenx
 
   
  
  1. RENAMENX key newkey
Sort
This usage is very complicated, it takes a little time
 
   
  
  1. < Span class= "PLN" >sort key [ by pattern [ limit offset Count [ get pattern [ get pattern ...] [ asc | DESC [ alpha Span class= "pun" > [ store destination
    • The sort key Returns the result of the key value from small to large.
    • sort key DESC Returns the result of the order of the key values from large to small.
Type
  
 
  1. Type Key
  2. return to   key  
  3. none   (key does not exist)
  4. string   (String)
  5. list   (list)
  6. set   (collection)
  7. zset   (ordered set)
  8. Hash (hash table)
Scan
 
   
  
  1. SCAN cursor [MATCH pattern] [COUNT count]









From for notes (Wiz)

Redis-key operation

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.