A high-performance, in-memory cache server written in Python with persistence support and multi-client capability.
- In-Memory Data Store: Fast key-value storage with O(1) access time
- Persistence Options:
- RDB (Database) snapshotting
- AOF (Append-Only File) logging
- Multi-Client Support: Handle concurrent connections via asyncio
- Memory Management:
- Configurable
maxmemorylimits - LRU eviction policy support
- Configurable
- TTL Expiration: Automatic key expiration with time-to-live
- Flexible Logging: Console or file-based logging with append/fresh modes
- Thread-Safe Operations: Async locks for concurrent access
pip install sterling-server
pip install -i https://test.pypi.org/simple/ sterling-server
git clone https://github.com/ghosecorp/sterling.git
cd sterling
pip install -e .
from sterling_server import SterlingServer
# Create server with default settings
server = SterlingServer()
server.run()
from sterling_server import SterlingServer
server = SterlingServer(
host='0.0.0.0', # Listen on all interfaces
port=9162, # Custom port
persistence_mode='RDB', # 'RDB' or 'AOF'
maxmemory=10000, # Max keys before eviction
eviction_policy='lru', # 'lru', 'allkeys-lru', or 'noeviction'
log_to_file=True, # Enable file logging
log_file_path='log/sterling.log',
fresh_logs=False # Append to existing logs
)
server.run()
| Parameter | Type | Default | Description |
|---|---|---|---|
host |
str | 'localhost' |
Server bind address |
port |
int | 9162 |
Server port |
persistence_mode |
str | 'RDB' |
Persistence strategy (RDB or AOF) |
maxmemory |
int | None |
Maximum keys in memory (None = unlimited) |
eviction_policy |
str | 'noeviction' |
How to handle memory limits |
log_to_file |
bool | False |
Log to file instead of console |
log_file_path |
str | None |
Custom log file path (default: log/server_logs.log) |
fresh_logs |
bool | False |
Start with fresh log file (True) or append (False) |
- Affects: ✅ Disk only
- Periodic snapshots of entire dataset
- Fast recovery, potential minor data loss
- Best for: Speed and simplicity
- Affects: ✅ Disk only
- Logs every write operation
- Maximum durability, larger files
- Best for: Critical data requiring minimal loss
| Feature | Affects RAM? | Affects Disk? | Purpose |
|---|---|---|---|
| Persistence (RDB/AOF) | ❌ | ✅ | Recovery after restart |
| maxmemory | ✅ | ❌ | Limit RAM usage |
| Eviction policy | ✅ | ❌ | Auto-delete old keys |
| TTL expiration | ✅ | ❌ | Auto-delete expired data |
See the examples/ directory for complete examples:
basic_server.py- Minimal server setupproduction_server.py- Production configuration with loggingcustom_persistence.py- Different persistence strategies
Performance Roadmap: Sterling Server will be gradually rewritten in C or Go (decision pending) to unlock:
- Hardware-level optimizations
- Native system integration
- Enhanced performance characteristics
- Advanced memory management
Commitment: We will continue maintaining and actively developing the Python version, incorporating features from the C/Go implementation whenever possible. The Python server remains our primary focus for users who prefer Python integration and ease of deployment.
Full documentation available at: https://github.com/ghosecorp/sterling/blob/main/README.md
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
See CHANGELOG.md for version history and updates.
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: ghosecorp@gmail.com
- sterling - Python client library
- Sterling clients for other languages (coming soon)
Built with ❤️ by Ghosecorp