Redis Data types

Source: Internet
Author: User
Tags bit set

Redis data types

Official website Documentation: Http://www.redis.io/topics/data-types-intro

Redis keys

Redis keys is binary safe, this means the can use any binary sequence as a key, from a string like "foo" to the Cont ent of a JPEG file. The empty string is also a valid key.

Redis key is binary safe, which means that you can use any binary sequence as a key from a string "foo" to the contents of a JPEG file. An empty string is also a valid key.

Rules

    • Key does not take too long, it consumes memory, and finding a key in a dataset may require more matching costs.
    • Key not too short, less readable,
    • Pursuit of a pattern "object-type:id" "comment:1234:reply.to" or "comment:1234:reply-to"
    • The maximum allowable value for key is 512M

Redis Client Redis-cli

View Help

REDIS-CLI--help

Specify block number

Redis-cli-n 0

Get help information for a command

Official website Help document: Http://www.redis.io/commands

Help @string get the data type string related Operations command

Help @list get the data Type list related Operations command

Help Set

Help <tab> Key Tips

String

Here is a brief description of the string type:

Help @string

APPEND Key value summary:append a value to a key since:2.0.0bitcount Key [start] [end] Summary:count set bitsinchAstringSince:2.6.0bitop Operation Destkey key [key ...] Summary:perform bitwise operations between strings since:2.6.0bitpos key bit [start] [end] summary:find first bit set orClear inchAstringSince:2.8.7decr key summary:decrement The integer value of a key by one since:1.0.0Decrby key Decrement summary:decrement The integer value of a key by the given number since:1.0.0GET Key Summary:get The value of a key since:1.0.0getbit key offset summary:returns The bit value at offsetinchThestringvalue stored at key since:2.2.0GETRANGE key start end summary:get A substring of thestringstored at a key since:2.4.0getset Key value Summary:set thestringvalue of a key and return its old value since:1.0.0INCR key summary:increment The integer value of a key by one since:1.0.0Incrby key Increment summary:increment The integer value of a key by the given amount since:1.0.0incrbyfloat key Increment summary:increment thefloatvalue of a key by the given amount since:2.6.0MGET key [key ...] Summary:get the values of all the given keys since:1.0.0MSET key value [key value ...] Summary:set multiple keys to multiple values since:1.0.1msetnx key value [key value ...] Summary:set multiple keys to multiple values, onlyifNone of the keys exist since:1.0.1Psetex key milliseconds value summary:set the value and expirationinchmilliseconds of a key since:2.6.0SET key value [EX seconds] [PX milliseconds] [NX|XX] Summary:set thestringvalue of a key since:1.0.0setbit key offset value summary:sets or clears the bit at offsetinchThestringvalue stored at key since:2.2.0Setex Key seconds value summary:set the value and expiration of a key since:2.0.0setnx Key value summary:set The value of a key, onlyifThe key does not exist since:1.0.0SETRANGE Key Offset value Summary:overwrite part of astringAt key starting at the specified offset since:2.2.0STRLEN Key Summary:get The length of the value storedincha key since:2.2.0

Setting the Key-value value

SET key value [EX seconds] [PX milliseconds] [nx| XX]

EX expiration time, seconds equivalent to Setex key seconds value

PX expiration time, milliseconds equivalent to Psetex key milliseconds value

The NX key does not exist to set the equivalent of SETNX key value

When the XX key is present, it can be set

Set multiple keys and value

MSET key value [key value ...] Msetnx key value [key value ...]   Value is set only if the key does not exist

Expiration settings

Set the number of seconds or milliseconds after expiration

EXPIRE Key seconds    sec pexpire key milliseconds  ms

Set the time stamp expiration on the specified UNIX

expireat Key Timestamp     sec pexpireat key milliseconds-timestamp    ms
PERSIST key  to delete expired key

View remaining time

TTL Keypttl Key

-1 TTL not set

-2 Find a key

Find key

KEYS pattern

* Any length character

? Any one character

[] Character Set

Increment count

INCR Key

Example:

Set Counter 100

INCR counter

101

Incrby key Increment  increment count based on the given value

Redis Data types

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.