Redis Basic Definition
Redis is an open‑source software written in ANSI C, network‑accessible key‑value database / storage system that supports in‑memory storage and data persistence. It provides client APIs for multiple programming languages.
- It belongs to NoSQL non‑relational databases;
- Similar to Memcached but with richer features, it makes up for many shortcomings of Memcached;
- Commonly used as a supplementary caching solution for relational databases such as MySQL.
Supported Data Types
String: String typeList: Doubly‑linked listSet: Unordered collectionzset(sorted set): Sorted collectionHash: Hash structure (similar to Map)
Memcached only supports string type, which is one of the most typical differences between them.
Features
- Multi‑language client support
Official SDKs are available for Java, C/C++, C#, PHP, JavaScript, Python, Ruby, Perl and many other languages for easy integration. - Master‑slave synchronization
Supports master‑slave replication for off‑site data backup and read‑write separation to improve service availability. - High performance
Data resides mainly in memory for extremely fast read and write performance, widely used as a distributed cache. - Data persistence
In‑memory data can be persisted to disk so data will not be fully lost after restart (Memcached has no persistence by default).
Background
The early Redis project was funded, developed and maintained by VMware.
We will demonstrate Redis usage with a simple WinForm(C#) Redis client demo, an introductory sample showing how C# connects to Redis.
- Set key‑value pairs
- Get value by key
Brief comparison: Redis vs Memcached
| Feature | Redis | Memcached |
|---|---|---|
| Data Types | 5 basic structures | String only |
| Persistence | Supports RDB/AOF persistence | No persistence support |
| Master‑Slave Replication | Supported | No native support |
| Memory Eviction | Multiple eviction policies | LRU eviction |
Introduction
Next: Installation