Sterling Server - In memory caching database
Project description
Sterling Server
A high-performance, in-memory cache server written in Python with persistence support and multi-client capability.
Features
- 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
Installation
Via PyPI
pip install sterling-server
Via TestPyPI
pip install -i https://test.pypi.org/simple/ sterling-server
From Source
git clone https://github.com/ghosecorp/sterling.git
cd sterling
pip install -e .
Quick Start
Basic Usage
from sterling_server import SterlingServer
# Create server with default settings
server = SterlingServer()
server.run()
Advanced Configuration
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()
Configuration Options
| 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) |
Persistence Strategies
RDB (Snapshot)
- Affects: ✅ Disk only
- Periodic snapshots of entire dataset
- Fast recovery, potential minor data loss
- Best for: Speed and simplicity
AOF (Append-Only File)
- Affects: ✅ Disk only
- Logs every write operation
- Maximum durability, larger files
- Best for: Critical data requiring minimal loss
Memory Management
| 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 |
Examples
See the examples/ directory for complete examples:
basic_server.py- Minimal server setupproduction_server.py- Production configuration with loggingcustom_persistence.py- Different persistence strategies
Future Development
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.
Documentation
Full documentation available at: https://github.com/ghosecorp/sterling/blob/main/README.md
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Changelog
See CHANGELOG.md for version history and updates.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: ghosecorp@gmail.com
Related Projects
- sterling - Python client library
- Sterling clients for other languages (coming soon)
Built with ❤️ by Ghosecorp
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sterling_server-0.1.0.tar.gz.
File metadata
- Download URL: sterling_server-0.1.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad19e689246f5766b9344f2f0778b055ab31d904a74f3198eb9bb09536d360dc
|
|
| MD5 |
d77158e7554596e8d5d3ddbeb17e23e4
|
|
| BLAKE2b-256 |
6571735a93ae445a86ea819ba30f6c887e6b7ab6975ae8e223bf95fd525e72b9
|
File details
Details for the file sterling_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sterling_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
032067b39d02ce2867d0b52fda206f6d496b698982a5410f44cfd5e1dcb172f6
|
|
| MD5 |
a5e3fc5738f8a63d64f384821841b049
|
|
| BLAKE2b-256 |
a0f3f121f598d7c2cfa16d195f83521bb47fdf05ec9cbe8b57ed7af8566d88c7
|