View on GitHub

marymafa.github.io


layout: post title: Redis date: 2018-04-16 —

redis

Redis is not a plain key-value store, actually, it is a data structures server, supporting a different kind of values. In traditional key-value stores, you associated string keys to string values, in Redis the value is not limited to a simple string, but can also hold more complex data structures.

Redis Strings:

Strings are Redis’ most basic data type. It is the only data type in Memcached, so it is also very natural for newcomers to use it in Redis. Since Redis keys are strings, when we use the string type as a value too, we are mapping a string to another string. The string data type is useful for a number of use cases, like caching HTML fragments or pages. Here are some common commands associated with strings:

SET: sets a value to a key
GET: gets a value from a key
DEL: deletes a key and its value
INCR: atomically increments a key
INCRBY: increments a key by a designated values
EXPIRE: the length of time that a key should exist (denoted in seconds)

It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster. Strings can be used to store objects, arranged by key.