not_redis
⚠️ Warning: This project was vibe-coded using OpenCode and MiniMax 2.1 Free. Code was generated by AI and may contain bugs, edge cases, or unexpected behavior. Review thoroughly before production use.
Description
not_redis is a Redis-compatible in-memory data structure library written in Rust. It provides Redis-like APIs without the networking overhead, external service dependencies, or operational complexity of running a Redis server.
Key Goals:
- Zero-config, embeddable Redis-compatible storage
- Thread-safe concurrent access via Tokio and DashMap
- RESP-compatible data types and command semantics
- No network overhead - runs in-process with your application
- Minimal dependencies for security and simplicity
Features
- Strings: GET, SET, DEL, EXISTS, EXPIRE, TTL, PERSIST
- Hashes: HSET, HGET, HGETALL, HDEL
- Lists: LPUSH, RPUSH, LLEN
- Sets: SADD, SMEMBERS
- Utilities: PING, ECHO, DBSIZE, FLUSHDB
Installation
[]
= "0.1"
Getting Started
use Client;
async
Async Runtime
not_redis requires a Tokio runtime. If you're using it in a non-Tokio context:
async
API Reference
Client
let mut client = new;
client.start.await;
| Method | Description |
|---|---|
get(key) |
Get value by key |
set(key, value) |
Set key-value pair |
del(key) |
Delete key, returns count |
exists(key) |
Check if key exists |
expire(key, seconds) |
Set key expiration |
ttl(key) |
Get remaining TTL (-2=missing, -1=no expiry, >=0=seconds) |
persist(key) |
Remove expiration, returns success |
flushdb() |
Clear all keys |
Hash Operations
| Method | Description |
|---|---|
hset(key, field, value) |
Set hash field |
hget(key, field) |
Get hash field |
hgetall(key) |
Get all fields/values |
hdel(key, field) |
Delete hash field |
List Operations
| Method | Description |
|---|---|
lpush(key, value) |
Push to list head |
rpush(key, value) |
Push to list tail |
llen(key) |
Get list length |
Set Operations
| Method | Description |
|---|---|
sadd(key, member) |
Add to set |
smembers(key) |
Get all members |
Utility Operations
| Method | Description |
|---|---|
ping() |
Returns "PONG" |
echo(msg) |
Echo message |
dbsize() |
Number of keys |
Thread Safety
not_redis uses DashMap for thread-safe concurrent access. Multiple threads can share a single Client instance.
use Arc;
use Client;
let client = new;
let client_clone = client.clone;
spawn;
Error Handling
use ;
match client.get.await
Why not_redis?
| Feature | Redis | not_redis |
|---|---|---|
| Setup | Requires Redis server | No setup needed |
| Network | TCP/IP overhead | In-process, zero-copy |
| Operations | Requires redis-cli or client | Direct API calls |
| Deployment | Additional service | Single binary |
Limitations
- No persistence (data lost on restart)
- No networking layer
- No clustering or replication
- Limited command set (growing)
- No Lua scripting
- No pub/sub
Contributing
Issues and PRs welcome. Note: This is a vibe-coded project - expect quirks.
License
MIT