Skip to main content

Management similar to redis interface

Project description

pydis

PyPI-version Python-version

English | 简体中文

Based on python's dict bottom layer, it implements management similar to redis interface

If you want to manage memory like redis, but don't want to introduce as many services as redis, you can use pydis, Of course, pydis is completely implemented based on python's dict, and only has the basic functions of redis. Please evaluate this carefully before using it.

install

pip install pydictdis

Usage

params

  • default_timeout : global timeout

simple usage

from pydis import Pydis


manager = Pydis()

manager.set("key1", "value1")
manager.get("key1")  # value1

manager.delete("key1")
manager.get("key1")  # None

ttl usage

from pydis import Pydis


manager = Pydis()
manager.set("key2", "value2", timeout=10)
print(manager.ttl("key2"))
# wait 10 seconds
manager.get("key2") # return None, because key2 already expired

incr and decr usage

from pydis import Pydis


manager = Pydis()

manager.set("key3", 0)
manager.incr("key3")
manager.incr("key3")
manager.incr("key3")
print(manager.get("key3"))  # 3

manager.decr("key3")
print(manager.get("key3"))  # 2

keys usage

from pydis import Pydis


manager = Pydis()

manager.set("key1", "value1")
print(list(manager.keys()))  # ["key1"]

set_nx

from pydis import Pydis


manager = Pydis()

manager.set_nx('key1', 'value')
manager.set_nx('key1', 'value1')
manager.get('key1')  # value

clean

from pydis import Pydis


manager = Pydis()

manager.set('key', 'value')
manager.set('key1', 'value1', timeout=1)
# after one seconds
manager.clean() # only have key in pydis, key1 already deleted

force_clean

from pydis import Pydis


manager = Pydis()
manager.set('key', 'value')
manager.set('key1', 'value1', timeout=1)
manager.force_clean()  # will delete all key

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

pydictdis-0.1.4.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

pydictdis-0.1.4-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file pydictdis-0.1.4.tar.gz.

File metadata

  • Download URL: pydictdis-0.1.4.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for pydictdis-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8f07cb0e6c1aa82d85c257de204887d6adc5d505d0b6fbf2959b422894f8ede0
MD5 10b0586da7d9d04610b2d0e2115c2029
BLAKE2b-256 631238b4220c18564887d6e403a5bee11ae4cdbd571c31d70ea3fb65e697be4a

See more details on using hashes here.

File details

Details for the file pydictdis-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: pydictdis-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for pydictdis-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3cb92f73471ca63f4129ed44caabaaf2381f1b6deea3a546584be6e5eb447438
MD5 ecaba11084788ec660743f3b612026d2
BLAKE2b-256 681ce7471eb066c5c0af2e1c2c991577735853cf947b139055ef53aa3bd01d53

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