Skip to main content

Python Client for DiceDB

Project description

🎲 DiceDB Python Client

Welcome to the DiceDB Python Client! This project provides an efficient way to interact with DiceDB using Python, managing connection pools and executing commands with ease.

How to Install

pip install dicedb-py

OR

poetry add dicedb-py

📝 Usage

import asyncio

from dicedb_py import Dice


async def main():
    dice = Dice(host="localhost", port=7379)
    print(await dice.set("foo", "bar"))
    val = await dice.get("foo")
    print(val)


if __name__ == "__main__":
    asyncio.run(main())

🛠️ Commands

  • SET: set key-value
    Ex: await dice.set("key", "val)

  • GET: get value from key
    Ex: await dice.get("key")

  • DEL: delete key
    Ex: await dice.delete("key")

  • EXISTS: check if a key exists & returns bool
    Ex: await dice.exists("key")

  • EXPIRE: sets ttl in seconds for a key
    Ex: await dice.expire("key", 10)

  • KEYS: get all keys in a list according to the pattern give. Use "_" for all keys.
    Ex: await dice.keys("_")

  • FLUSH: clear all keys
    Ex: await dice.flush()

  • INCR: incr key by 1. Default value to start is 0 if key is not already set.
    Ex: await dice.incr("key")

  • INCRBY: incr key by amount (int)
    Ex: await dice.incrby("key", 2)

  • DECR: decr key by 1.
    Ex: await dice.decr("key")

  • DECRBY: decr key by amount (int)
    Ex: await dice.decrby("key", 2)

  • TTL: get TTL (time to live) of the key in seconds
    Ex: await dice.ttl("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

dicedb_py-0.0.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

dicedb_py-0.0.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file dicedb_py-0.0.2.tar.gz.

File metadata

  • Download URL: dicedb_py-0.0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.15 Linux/6.5.0-1025-azure

File hashes

Hashes for dicedb_py-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a3e06f3fc704418f726915102768228e8c7f198781480e21e5c8f94def29c896
MD5 4540771aebe34d23b28e018d17d60933
BLAKE2b-256 fe9c77ea457b836f405efbe4510e86fe6e041e3d0bad2d565f52fe47a050f125

See more details on using hashes here.

File details

Details for the file dicedb_py-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: dicedb_py-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.15 Linux/6.5.0-1025-azure

File hashes

Hashes for dicedb_py-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b583f8780926a2159d953ee0066ef3f6372ddfa9fe82d3bac0c718a9c2041056
MD5 44ac334655feda86a16ff8b54997fde3
BLAKE2b-256 e83db1d6bb6bd3d39d56ed7b23332a8c358ba654cb0b39e967b0012bcce8c411

See more details on using hashes here.

Supported by

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