https://vercel.com/docs/storage/vercel-kv/rest-api
Project description
vercel-kv-sdk
vercel-kv-sdk is a simple toolkit for vercel kv db which warped from vercel REST API
QuickStart
install
pip install vercel-kv-sdk
Connect to a project
Pull your vercel kv environment variables
vercel env pull .env.development.local
run this code to make the latest environment variables available to your project locally
rename your environment variables file
mv .env.development.local .env
then you can use vercel_kv_sdk in your project
from vercel_kv import KV
kv = KV()
kv.set("count",1)
count = kv.get("count")
print(f"now count is {count}")
# now count is 1
Using Options
In the SET command of Redis, there are several available options to configure the behavior of the command. Here are some common options in the SET command and their descriptions:
Options | Description |
---|---|
ex | Set the expiration time of the key in seconds. The key will be automatically deleted after the specified number of seconds. |
px | Set the expiration time of the key in milliseconds. The key will be automatically deleted after the specified number of milliseconds. |
exat | Set the value of the key only if it does not exist. If the key already exists, the SET command does not take effect. |
pxat | Set the value of the key only if it already exists. If the key does not exist, the SET command does not take effect. |
keepTtl | Preserve the existing expiration time of the key. Only used when overriding an existing key. |
These options can be combined. For example, you can set the expiration time of the key to 10 seconds and set the value only if the key does not exist using the EX and NX options: SET key value EX 10 NX.
It is important to note that using options can have a certain impact on the performance of Redis, as additional operations will increase the overhead of command execution. Therefore, options should be used cautiously based on the actual requirements.
Example
kv = KV()
kv.set('temp','hello',ex=5)
print(f"now temp is {kv.get('temp')},and wait for 5 seconds...") # now temp is hello
time.sleep(5)
print(f"now temp is {kv.get('temp')}") # now temp is None
TODO
- more user-friendly options input
- complete functions: hset,hget
This project was forked from the python-vercel-kv project and improved,Lowering the python version threshold
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 vercel_kv_sdk-0.1.2.tar.gz
.
File metadata
- Download URL: vercel_kv_sdk-0.1.2.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6c3613f4a0ac5c698416bdb2b1ab7b6f922f849bd9227dc67e8d371df65f833 |
|
MD5 | 916e26ef2d9f2e9fb8b24c741a60ca14 |
|
BLAKE2b-256 | f1b46dbd185d234e2f08558bbfc0f05ac632ae8597b9360054ee8ec72e0db33d |
File details
Details for the file vercel_kv_sdk-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: vercel_kv_sdk-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86f91d5e292356d005f1a7cfa0f4208ac5ed82d5baf88b9a8b0980092e4afb71 |
|
MD5 | 04eb433460eb63b6f35fc3886cc6ac08 |
|
BLAKE2b-256 | d30cfe1b45ddc8095c13bdda7f51669595e81a981c50349f691bf1dff28bc365 |