asyncio wrapper of aerospike python client library
This project is work in progress. please do not use it in production yet.
This project provides a simple way to use aerospike with asyncio.
This project is based on Aerospike python client library docs Docs
installation
pip install aio-aerospike-python
Quick start
start docker compose
docker compose up -d
from aio_aerospike_python import AioAerospikeClient
import asyncio
config = {
'hosts': [('0.0.0.0', 3000)]
}
client = AioAerospikeClient(config)
print(client.is_connected())
async def put_some_data(limit:int):
for i in range(limit):
key = ("test","test",i)
data = {"a":i}
await client.put(key,data)
async def read_data(limit:int):
for i in range(limit):
key = ("test","test",i)
r = await client.get(key)
print(r)
loop = asyncio.get_event_loop()
loop.run_until_complete(put_some_data(33))
loop.run_until_complete(read_data(33))
client.close()
Now lets test it with concurrency
from aio_aerospike_python import AioAerospikeClient
from aio_aerospike_python import exception
from aerospike_helpers import expressions as exp
import aerospike
import asyncio
config = {
'hosts': [('0.0.0.0', 3000)]
}
client = AioAerospikeClient(config)
print(client.is_connected())
async def put_some_data(limit: int):
for i in range(limit):
key = ("test", "test", i)
data = {"a": i}
await client.put(key, data)
async def read_data(limit: int):
keys = [("test", "test", i) for i in range(limit) ]
# print(keys)
r = await client.get_many(keys)
print(r)
async def use_query(mina: int, maxa: int):
query = client.query("test", "test")
expr = expr = exp.And(
exp.LT(exp.IntBin("a"), maxa),
exp.GT(exp.IntBin("a"), mina)
).compile()
scan_policy = {"expressions": expr}
results = await query.results(scan_policy)
print("query results ===")
for r in results:
print(r)
async def use_scan(mina: int, maxa: int):
scan = client.query("test", "test")
expr = exp.And(
exp.LT(exp.IntBin("a"), maxa),
exp.GT(exp.IntBin("a"), mina)
).compile()
scan_policy = {"expressions": expr}
results = await scan.results(scan_policy)
print("scan results ===")
for r in results:
print(r)
async def test_append(key=("test","test",3), bin="a", val="test", meta=None, policy=None):
await client.put(key=key, bins={"vv":"test_"})
await client.append(key=key, bin="vv", val="append", meta=meta, policy=policy)
r = await client.get(key=key)
key, _, bin = r
print("append")
print(r)
async def main():
L = await asyncio.gather(
put_some_data(700),
read_data(50),
use_query(10, 20),
use_scan(40, 45),
test_append()
)
asyncio.run(main())
License
The AIO Aerospike Python Client is made available under the terms of the Apache License, Version 2, as stated in the file LICENSE.
Metadata
Release files for aio-aerospike-python 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| aio_aerospike_python-0.0.5.tar.gz | 16.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aio_aerospike_python-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.6 kB
Release files / aio_aerospike_python-0.0.5.tar.gz
| Download URL | aio_aerospike_python-0.0.5.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
715cfe07c1cebb8bdd415514a9763158ad45b77fe13a7d724a4f5562a0d538f0
|
|
BLAKE2b-256 checksum How to use checksums |
df3ff60a1ff3105e34f3c7b81ed219d2a3f5699cec3ea99f9717e83839052920
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / aio_aerospike_python-0.0.5-py3-none-any.whl
| Download URL | aio_aerospike_python-0.0.5-py3-none-any.whl |
|---|---|
| Size | 16.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e65ffc57cf64d2d8d4a369527b2a882458392dd04c3922519fd5e0bfef9ad311
|
|
BLAKE2b-256 checksum How to use checksums |
1d2379623d5882741cad851363ef91181a8264529edc0fec2c980ba37ee471e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for aio-aerospike-python 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.