All Projects → chekart → rediserver

chekart / rediserver

Licence: MIT license
Pure Python Redis server implementation

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to rediserver

redi-s
A performant Redis server implemented in SwiftNIO.
Stars: ✭ 69 (+165.38%)
Mutual labels:  redis-server
readis
Lightweight web frontend in PHP for reading data, stats and config from multiple redis servers.
Stars: ✭ 38 (+46.15%)
Mutual labels:  redis-server
sessionx
Go's web session library.
Stars: ✭ 75 (+188.46%)
Mutual labels:  redis-server
Redis-Windows-32bit
The Windows 64-bit/32-bit bin files for Redis can download there
Stars: ✭ 53 (+103.85%)
Mutual labels:  redis-server
hanbo-db
hanboDB is a high available,low latency memory database system
Stars: ✭ 29 (+11.54%)
Mutual labels:  redis-server
keva
Low-latency in-memory key-value store, Redis drop-in alternative
Stars: ✭ 76 (+192.31%)
Mutual labels:  redis-server
python-keylogger
Advanced Pure-Python Keylogger
Stars: ✭ 64 (+146.15%)
Mutual labels:  pure-python
MsCoreOne
MsCoreOne is a simple Ecommerce with using many technologies such as .NET 5, Entity Framework Core 5, React 16.13 with modern Clean Architecture, Domain-Driven Design, CQRS, SOLID, Identity Server 4, Blazor. It will focus on resolving the problems always see in the process to develop projects.
Stars: ✭ 77 (+196.15%)
Mutual labels:  redis-server
redis-developer.github.io
The Home of Redis Developers
Stars: ✭ 28 (+7.69%)
Mutual labels:  redis-server
redis
Redis server written in Go / Golang (prototype)
Stars: ✭ 53 (+103.85%)
Mutual labels:  redis-server
rancher-redis
A containerized redis master/slave configuration with sentinels for use in Rancher
Stars: ✭ 13 (-50%)
Mutual labels:  redis-server
CRDT-Redis
CRDTs implemented in Redis
Stars: ✭ 35 (+34.62%)
Mutual labels:  redis-server
terraform-aws-elasticache
Terraform module to create Elasticache Cluster and replica for Redis and Memcache.
Stars: ✭ 19 (-26.92%)
Mutual labels:  redis-server
The-Overly-Complicated-Random-Number-Generator
An Overly Complex Random Number Generator, created to demystify how containers work.
Stars: ✭ 25 (-3.85%)
Mutual labels:  redis-server
phpRebloom
🎛️ Use RedisBloom in PHP!
Stars: ✭ 20 (-23.08%)
Mutual labels:  redis-server
centminmod-magento2
Magento 2.2.2 Install Guide For Centmin Mod Nginx LEMP Stacks
Stars: ✭ 16 (-38.46%)
Mutual labels:  redis-server
phpRedisTimeSeries
📈 Use Redis Time Series in PHP!
Stars: ✭ 23 (-11.54%)
Mutual labels:  redis-server
redis-patterns-console
An interactive (and reactive) console to try and go into the deep of Redis and its patterns!
Stars: ✭ 22 (-15.38%)
Mutual labels:  redis-server
core
Simple JSON-based messaging queue for inter service communication
Stars: ✭ 28 (+7.69%)
Mutual labels:  redis-server
redface
RedFace means redis interface.
Stars: ✭ 23 (-11.54%)
Mutual labels:  redis-server

Build Status

rediserver

Pure Python Redis server implementation

Getting Started

It is possible to use Redis server as standalone redis installation, however the main goal of the project is to have an in-mem lightweight Redis for python Unit Tests.

The package provides context manager named local_redis which created separate thread running fresh new redis on enter and stops on exit. Context manager returns proxy object to access redis data

import redis
from rediserver.test import local_redis

# start redis server
with local_redis() as redis_proxy:
    # redis_proxy contains sock property a tempfile path to redis unix socket
    # pass it to python redis client
    client = redis.StrictRedis(unix_socket_path=redis_proxy.sock)
    client.set('key1', 1)
    # dict property returns a deepcopy of redis keys, feel free to modify it
    # and check whether data is created
    # please note that data stored as bytes
    assert redis_proxy.dict == {b'key1': b'1'}

pytest

The package provides pytest fixture, use it like this

# in conftest.py
pytest_plugins = 'rediserver.test.pytest',

def test_ok(local_redis):
    client = redis.StrictRedis(unix_socket_path=local_redis.sock)
    ...

Compatibility

Currently redis server supports the following methods:

  • Keys
    • GET, SET, DEL, INCRBY, DECRBY, SCAN
  • Sets
    • SADD, SPOP, SCARD
  • Scripts
    • SCRIPT LOAD, EVALSHA
  • Transactions:
    • MULTI, WATCH, EXEC

Embedded Redis

Need a real redis instance to be flushed for each test? Say no more. You can use EmbeddedRedis and EmbeddedRedisSession context managers

EmbeddedRedis context manager runs a docker redis container on enter and stops it on exit. The return value of the container is a temporary socket file to use for connecting server. It's also possible to use start and stop methods of EmbeddedRedis directly

import redis
from rediserver import EmbeddedRedis

with EmbeddedRedis() as socket_file:
    client = redis.StrictRedis(unix_socket_path=embedded_redis_server)
    client.set('some_key', 'some_value')

EmbeddedRedisSession is a context manager that flushes current redis db on exit In case of multithreaded testing, each thread has to run session using separate db (the current redis db limit if using EmbeddedRedis is set to 100). Returned value is a redis proxy object similar to local_redis

redis_server = EmbeddedRedis()
socket = redis_server.start()

client = redis.StrictRedis(unix_socket_path=redis_proxy.sock, db=thread_db)

with EmbeddedRedisSession(socket_file=socket, db=thread_db) as redis_proxy:
    client.set('some_key', 'some_value')

client.get('some_key') # value is None
redis_server.stop()

pytest

The package provides the following pytest fixtures to use.

embedded_redis_server - creates redis server instance, with the scope of session

embedded_redis - flushes redis db before and after the test

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].