A lightweight, Redis-compatible Python client for Valkeyrie distributed cache system.
pip install valkeyriefrom valkeyrie import ValkeyreClient
# Connect to Valkeyrie server
with ValkeyreClient('localhost', 6379) as client:
# SET and GET
client.set('user:1001', 'Alice')
value = client.get('user:1001')
print(value) # 'Alice'
# Check existence
if client.exists('user:1001'):
print("Key exists!")
# Set expiration (TTL)
client.expire('user:1001', 300) # 5 minutes
# Delete key
client.delete('user:1001')- ✅ Full RESP protocol support
- ✅ Context manager for automatic connection handling
- ✅ Simple, intuitive API
- ✅ Compatible with Redis commands
- ✅ No external dependencies
- ✅ Python 3.7+
client = ValkeyreClient(host='127.0.0.1', port=6379)
client.connect()
client.disconnect()| Method | Description |
|---|---|
set(key, value) |
Set key to value |
get(key) |
Get value by key |
delete(key) |
Delete key |
exists(key) |
Check if key exists |
expire(key, seconds) |
Set expiration time |
keys() |
Get all keys |
info() |
Get cache statistics |
ping() |
Test connection |
from valkeyrie import ValkeyreClient
client = ValkeyreClient('localhost', 6379)
client.connect()
# Store user session
client.set('session:abc123', 'user_data')
client.expire('session:abc123', 3600)
# Retrieve session
session = client.get('session:abc123')
# Get all keys
all_keys = client.keys()
# Get cache stats
stats = client.info()
print(stats)
client.disconnect()- Python 3.7+
- Running Valkeyrie server
MIT License