Skip to main content

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.

PyPI version Python 3.8+ License: MIT

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 maxmemory limits
    • LRU eviction policy support
  • 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 setup
  • production_server.py - Production configuration with logging
  • custom_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

Related Projects

  • sterling - Python client library
  • Sterling clients for other languages (coming soon)

Built with ❤️ by Ghosecorp

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sterling_server-0.1.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sterling_server-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

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

Hashes for sterling_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ad19e689246f5766b9344f2f0778b055ab31d904a74f3198eb9bb09536d360dc
MD5 d77158e7554596e8d5d3ddbeb17e23e4
BLAKE2b-256 6571735a93ae445a86ea819ba30f6c887e6b7ab6975ae8e223bf95fd525e72b9

See more details on using hashes here.

File details

Details for the file sterling_server-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sterling_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 032067b39d02ce2867d0b52fda206f6d496b698982a5410f44cfd5e1dcb172f6
MD5 a5e3fc5738f8a63d64f384821841b049
BLAKE2b-256 a0f3f121f598d7c2cfa16d195f83521bb47fdf05ec9cbe8b57ed7af8566d88c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page