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

config

from pydis import Pydis

manager = Pydis()

manager.set_config("default_timeout", 50) # set default timeout is 50 seconds

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.5.tar.gz (9.0 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.5-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydictdis-0.1.5.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pydictdis-0.1.5.tar.gz
Algorithm Hash digest
SHA256 f13a67e1ab9a984569478e5e4c5150b2153faa50ecfec7791a35d0736b6f2930
MD5 34e8f4c5640b6dc11655a7367e1167dc
BLAKE2b-256 939512336edfe363bfde4e86170da2650f035680098653287f4c4927d2cacbac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydictdis-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pydictdis-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c9416724523881c4ac881ca0a91e38187db2d2d001234097874a213fb8be2ce1
MD5 b0e69fa9da283bda75bc54c997cbd832
BLAKE2b-256 7b37e9f5f8d2c9209d0339a8058df18e89b7e43b6648031fdf987c70d607b96f

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