User Tools

Site Tools


redis

Redis

Return to Conflict-free replicated data type, Valkey (Redis's successor as a free software project), Memcached, Infinispan

Redis is an open-source, in-memory data structure store widely employed as a database, cache, and message broker. It's renowned for its exceptional performance, versatility, and support for a rich set of data structures. Redis primarily stores data in memory, enabling lightning-fast read and write operations, while also offering persistence options to safeguard data durability.

Key Features

  • **In-Memory Data Store:** Redis primarily resides in memory, delivering exceptional speed for data access and manipulation.
  • **Rich Data Structures:** It supports a diverse array of data structures beyond simple key-value pairs, including lists, sets, sorted sets, hashes, bitmaps, hyperloglogs, and streams. This versatility empowers you to model and manipulate data effectively for various use cases.
  • **Persistence:** While primarily in-memory, Redis provides options for persisting data to disk, either through snapshotting or append-only file (AOF) logging.
  • **Pub/Sub Messaging:** Redis incorporates a publish/subscribe messaging system, enabling real-time communication and event-driven architectures.
  • **Transactions:** It supports multi-key operations within transactions, ensuring atomicity and data consistency.
  • **Lua Scripting:** Redis allows executing Lua scripts on the server-side, enabling complex operations and data transformations.
  • **High Availability:** Redis Cluster provides high availability and automatic failover through data sharding and replication across multiple nodes.

Benefits

  • **Exceptional Performance:** Redis's in-memory nature delivers blazing-fast read and write operations, making it ideal for caching, real-time applications, and high-performance systems.
  • **Versatility:** Its diverse data structures and extensive feature set make Redis adaptable to a wide range of use cases, from simple key-value storage to complex data modeling and messaging.
  • **Scalability:** Redis can scale horizontally through clustering, handling large datasets and high traffic volumes.
  • **Ease of Use:** Its simple and intuitive command interface makes it easy to learn and integrate into your applications.
  • **Active Community:** Redis boasts a large and active community, offering abundant resources, documentation, and support.

Code Examples

1. **Setting and Getting a Key-Value Pair (Python):**

```python import redis

r = redis.Redis(host='localhost', port=6379, db=0) r.set('mykey', 'Hello, Redis!') value = r.get('mykey') print(value) # Output: b'Hello, Redis!' ```

2. **Adding Elements to a List (Node.js):**

```javascript const redis = require('redis');

const client = redis.createClient();

client.rpush('mylist', 'apple', 'banana', 'orange'); client.lrange('mylist', 0, -1, (err, reply) ⇒ {

   console.log(reply); // Output: [ 'apple', 'banana', 'orange' ]
}); ```

3. **Publishing a Message (Ruby):**

```ruby require 'redis'

redis = Redis.new

redis.publish('mychannel', 'Hello, subscribers!') ```

These examples showcase basic Redis operations using different client libraries.

Additional Resources


Snippet from Wikipedia: Redis

Redis (; Remote Dictionary Server) is a source-available, in-memory storage, used as a distributed, in-memory key–value database, cache and message broker, with optional durability. Because it holds all data in memory and because of its design, Redis offers low-latency reads and writes, making it particularly suitable for use cases that require a cache. Redis is the most popular NoSQL database, and one of the most popular databases overall. Redis is used in companies like Twitter, Airbnb, Tinder, Yahoo, Adobe, Hulu, Amazon and OpenAI.

Redis supports different kinds of abstract data structures, such as strings, lists, maps, sets, sorted sets, HyperLogLogs, bitmaps, streams, and spatial indices.

The project was developed and maintained by Salvatore Sanfilippo, starting in 2009. From 2015 until 2020, he led a project core team sponsored by Redis Labs. Salvatore Sanfilippo left Redis as the maintainer in 2020. In 2021 Redis Labs dropped the Labs from its name and now is known simply as "Redis".

In 2018, some modules for Redis adopted the SSPL. In 2024, the main Redis code switched to dual-licensed under the Redis Source Available License v2 and the Server Side Public License v1.

Fair Use Sources


© 1994 - 2024 Cloud Monk Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


redis.txt · Last modified: 2024/08/26 12:53 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki