Metadata-Version: 2.1
Name: py-kvstore
Version: 0.0.7
Summary: A key value store
Home-page: https://github.com/Reecepbcups/py_kvstore
Author: Reece Willims
Author-email: reecepbcups@gmail.com
License: Apache 2.0
Classifier: Development Status :: 1 - Planning
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Description-Content-Type: text/markdown

# Python KVStore

[pypi py-kvstore](https://pypi.org/project/py-kvstore/)

---

A simple Key-Value store (similar to redis) built in python.

Sets can expire, not expire, and be saved with any arbitrary data. So you can set it as a JSON string, a dict, int, or any other value. It is up to the developer to implement and parse types correctly.

---

## Projects Using

- [CosmosSDK Endpoint Cache](https://github.com/Reecepbcups/cosmos-endpoint-cache)

---

## Notable Features

```py
# create a new KVStore
kv1 = KVStore(name="transactions", dump_dir="/home/reece/kvstores")

# Set a key. Defaults to -1 timeout (no timeout)
kv1.set("tx;UUID-HERE", "{"data":{"time":"...","amount":"...","currency":"..."}}")

# Get the key, returns None if not found (ex: expired or never set)
res = kv1.get("tx;UUID-HERE")

# Set this key to expire in 100 seconds
kv1.set("other;expire_later", "some string here", 100)

# Store data in multiple sub keys (hashset).
# You can only set a timeout on the parent key for now IF its a new set. Else use .hset_expire(...)
kv1.hset("parent_key", "subkey1", "value", 10)
kv1.hset("parent_key", "subkey2", "value2")

kv1.hget("parent_key", "subkey1") # returns "value"

# Set values and increment a counter
kv1.set("counter", 0)
kv1.incr("counter") # returns 1
kv1.incr("counter", amount=4) # returns 5

# Keys
kv1.get_keys() # returns all non expired keys
kv1.get_keys("tx;*") # returns keys matching the regex

# Save current memory state to disk (the dump_dir set on initialize.)
kv1.dump()

# clear the store
kv1.clear()

# Load the previous dump from file
kv1.load()
```


