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
Release files for sterling-server 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sterling_server-0.1.0.tar.gz | 7.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sterling_server-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.3 kB
Release files / sterling_server-0.1.0.tar.gz
| Download URL | sterling_server-0.1.0.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad19e689246f5766b9344f2f0778b055ab31d904a74f3198eb9bb09536d360dc
|
|
BLAKE2b-256 checksum How to use checksums |
6571735a93ae445a86ea819ba30f6c887e6b7ab6975ae8e223bf95fd525e72b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sterling_server-0.1.0-py3-none-any.whl
| Download URL | sterling_server-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
032067b39d02ce2867d0b52fda206f6d496b698982a5410f44cfd5e1dcb172f6
|
|
BLAKE2b-256 checksum How to use checksums |
a0f3f121f598d7c2cfa16d195f83521bb47fdf05ec9cbe8b57ed7af8566d88c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|