Skip to content

mentalblood0/bottomless_ReJSON

Repository files navigation

bottomless_ReJSON

Library for seamless Redis database management. This version uses RedisJSON module


  • 💤 No excess data reading/rewriting
  • 🗃 Integrated indexes support
  • ⛓ Thread-safe operations
  • 👁️ One-class interface
  • 🪄 A lot of sugar

💿 Installation

python -m pip install bottomless_ReJSON

✒️ Usage

Here are just a few examples

Feel free to use the tests as a manual

Preparations

from bottomless_ReJSON import RedisInterface

db = RedisInterface(host='localhost', port='6379')

Dictionary-like interface

db.clear()
d = {
    '1': {
        '1': {
            '1': 'one.one.one'
        },
        '2': 'one.two'
    },
    '2': 'two'
}
db |= d
assert db() == d

db['2'] = d
assert db['2']() == d

db['1']['1'] = 'lalala'
assert db['1']['1'] == 'lalala'
assert db['1']['1']['1'] == None

List-like interface

db.clear()
db['key'] = []
db = db['key']

l = [1, 2, 3]
db += [1, 2, 3]

i = 0
for e in db:
    # e is RedisInterface instance,
    # so to get data you need to call it:
    assert e() == l[i]
    assert e() == db[i]
    i += 1

    assert list(db) == [1, 2, 3]

🔬 Testing

git clone https://codeberg.org/mentalblood/bottomless_ReJSON
cd bottomless_ReJSON
pytest tests

📈 Benchmarking

Using sharpener:

git clone https://codeberg.org/mentalblood/bottomless_ReJSON
cd bottomless_ReJSON
py -m sharpener run

Config for benchmarks can be found in benchmarks/benchmark_default.json

About

Library for seamless Redis database management

Topics

Resources

License

Stars

Watchers

Forks

Languages