What is Valkey
Valkey is a high-performance key-value in-memory database with rich data structures, ideal for caching, message queues, session storage, and more.
Background: Valkey is an open-source fork of Redis (BSD license), maintained by the Linux Foundation community after Redis changed its license. It is fully API-compatible and can be used as a drop-in replacement.
Key Features
- Rich Data Structures: String, Hash, List, Set, Sorted Set, Stream, Bitmap, HyperLogLog, and more
- In-Memory + Persistence: Data operates primarily in memory, with both RDB snapshots and AOF log persistence
- High Performance: Single-threaded model avoids lock contention; a single instance can handle 100K+ QPS
- Publish/Subscribe: Built-in Pub/Sub messaging with pattern-based subscriptions
- Lua Scripting: Atomic Lua script execution for transactional complex operations
- Cluster Mode: Native data sharding and automatic failover support
- Module System: Extend functionality via C modules (e.g., RediSearch, RedisJSON)
Common Use Cases
| Scenario | Description | Data Structure |
|---|---|---|
| Caching | Reduce database load, accelerate hot data reads | String / Hash |
| Session Store | Distributed session management with TTL auto-expiry | String / Hash |
| Leaderboard | Real-time ranking with score updates and range queries | Sorted Set |
| Message Queue | Lightweight task queue with consumer groups | Stream / List |
| Distributed Lock | Mutual exclusion for shared resources across nodes | String (SET NX) |
| Counter | Real-time stats for article views, likes, etc. | String (INCR) |
Architecture Overview
Valkey uses a single-threaded event loop model (I/O threads are optionally multi-threaded). The core architecture includes:
- Event Loop: I/O multiplexing based on epoll/kqueue for client connections and command execution
- Memory Management: Uses the jemalloc allocator to reduce fragmentation; controls memory limits via
maxmemorypolicies - Persistence Engine: RDB generates snapshots via fork child process; AOF records every write command and replays on restart
- Replication: Asynchronous master-replica replication with cascading and partial resynchronization (PSYNC)
Quick Start
After installation, connect via the command-line client and run basic operations:
$ valkey-cli 127.0.0.1:6379> SET mykey "Hello Valkey" OK 127.0.0.1:6379> GET mykey "Hello Valkey" 127.0.0.1:6379> INCR counter (integer) 1 127.0.0.1:6379> INCR counter (integer) 2 127.0.0.1:6379> TTL mykey (integer) -1
Security Notice: By default, Valkey has no password and listens on all network interfaces. In production, always configure requirepass and bind parameters.
Relationship with Redis
Valkey is a direct fork of Redis 7.2, maintaining full command and data format compatibility. Key differences:
- Valkey is managed by the Linux Foundation under an OSI-approved open-source license
- Community-driven development with a more transparent contribution process
- Ongoing performance optimizations — 5-10% improvement over Redis 7.2 in some scenarios
- All existing Redis clients and tools can connect to Valkey seamlessly