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.
📝 Usage
import asyncio
from dicedb_py import Dice
async def test():
dice = Dice("localhost", 7379)
import time, random
start_time = time.time()
while (time.time() - start_time) < 600:
x = await dice.set("foo", "bar")
print(x)
val = await dice.get("foo")
print(val)
sleep = random.randint(15, 30)
print(f"Sleeping for {sleep} seconds.")
await asyncio.sleep(sleep)
asyncio.run(test())
🛠️ 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dicedb_py-0.0.1.tar.gz
.
File metadata
- Download URL: dicedb_py-0.0.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | c47b8303542c1bfba34efb3bcf5d7a42c378ca61f89ea1a272b7e25e98e6d203 |
|
MD5 | 7ad2ac57d3430d9602082421c7c9e850 |
|
BLAKE2b-256 | 9a40ebb810ef41ce1a6132d56c76d8300ed86ec9a8cf20390b0fedca95c4e760 |
File details
Details for the file dicedb_py-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: dicedb_py-0.0.1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7fa4e6fd92a0e2f3c4dc929a8820b032e60bbe09886433afe69fb311d4770df |
|
MD5 | 79562dd94a4364c58c252216d68eb0d8 |
|
BLAKE2b-256 | 1699f2e36ee8ece034ea8126c50736028062a4baa06b8c5dd2df83cab3a630d6 |