A pure-Python(3.7+) asyncio memcached client, fork from aiomcache.
Project description
A pure-Python(3.7+) asyncio memcached client, fork from aiomcache.
Author |
Nikolay Kim <fafhrd91@gmail.com> |
Maintainer |
Rex Zhang <rex.zhang@gmail.com> |
Contributions |
Andrew Svetlov <andrew.svetlov@gmail.com> |
Install
pip install -U AioMemcached
Usage
Base command examples
Code
import asyncio
import aiomemcached
KEY_1, KEY_2 = b'k1', b'k2'
VALUE_1, VALUE_2 = b'1', b'v2'
async def base_command():
client = aiomemcached.Client()
print('--- version() ---')
print(await client.version())
print()
print('--- set(KEY1, VALUE_1), get(KEY_1) ---')
await client.set(KEY_1, VALUE_1)
value, info = await client.get(KEY_1)
print(value, info)
print('--- after incr(KEY_1), get(KEY_1) ---')
await client.incr(KEY_1)
value, info = await client.get(KEY_1)
print(value, info)
print('--- after decr(KEY_1), get(KEY_1) ---')
await client.decr(KEY_1)
value, info = await client.get(KEY_1)
print(value, info)
print('--- gets(KEY_1) ---')
value, info = await client.gets(KEY_1)
print(value, info)
print()
keys = [KEY_1, KEY_2]
print('--- get_many() ---')
values, info = await client.get_many(keys)
print(values, info)
print('--- gets_many() ---')
values, info = await client.gets_many(keys)
print(values, info)
print('--- after set(KEY2, VALUE_2), gets_many() ---')
await client.set(KEY_2, VALUE_2)
values, info = await client.gets_many(keys)
print(values, info)
print('--- after delete(KEY_1), gets_many() ---')
await client.delete(KEY_1)
value, info = await client.gets_many(keys)
print(value, info)
print()
print('--- set(KEY2, VALUE_2), get(KEY_2) ---')
await client.set(KEY_2, VALUE_2)
value, info = await client.get(KEY_2)
print(value, info)
print('--- after append(KEY_2, b"append"), get(KEY_2) ---')
await client.append(KEY_2, b'append')
value, info = await client.get(KEY_2)
print(value, info)
print('--- after flush_all(), get_many() ---')
await client.flush_all()
values, info = await client.get_many(keys)
print(values, info)
return
if __name__ == '__main__':
asyncio.run(base_command())
Output
--- version() ---
b'1.6.6'
--- set(KEY1, VALUE_1), get(KEY_1) ---
b'1' {'flags': 0, 'cas': None}
--- after incr(KEY_1), get(KEY_1) ---
b'2' {'flags': 0, 'cas': None}
--- after decr(KEY_1), get(KEY_1) ---
b'1' {'flags': 0, 'cas': None}
--- gets(KEY_1) ---
b'1' {'flags': 0, 'cas': 11248}
--- get_many() ---
{b'k1': b'1'} {b'k1': {'flags': 0, 'cas': None}}
--- gets_many() ---
{b'k1': b'1'} {b'k1': {'flags': 0, 'cas': 11248}}
--- after set(KEY2, VALUE_2), gets_many() ---
{b'k2': b'v2', b'k1': b'1'} {b'k2': {'flags': 0, 'cas': 11249}, b'k1': {'flags': 0, 'cas': 11248}}
--- after delete(KEY_1), gets_many() ---
{b'k2': b'v2'} {b'k2': {'flags': 0, 'cas': 11249}}
--- set(KEY2, VALUE_2), get(KEY_2) ---
b'v2' {'flags': 0, 'cas': None}
--- after append(KEY_2, b"append"), get(KEY_2) ---
b'v2append' {'flags': 0, 'cas': None}
--- after flush_all(), get_many() ---
{} {}
Development
Coverage Report
python -m pytest --cov=. --cov-report html
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
AioMemcached-0.8.1.tar.gz
(15.5 kB
view details)
Built Distribution
File details
Details for the file AioMemcached-0.8.1.tar.gz
.
File metadata
- Download URL: AioMemcached-0.8.1.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 347f5a347af50fb3159678909818ee1f4719df09425e7e0695d430d935762f28 |
|
MD5 | 65da8ed1fbecdbc65d30977337fa3aa1 |
|
BLAKE2b-256 | e5d043df746abdaa743618313e4fffd6831bccb240220a74fedfc9d1e70c7dde |
File details
Details for the file AioMemcached-0.8.1-py2.py3-none-any.whl
.
File metadata
- Download URL: AioMemcached-0.8.1-py2.py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88e005aba7143dfa3ea6c5f8879ae363889b8488e2e0cdcb902a6b5635437241 |
|
MD5 | a6d64b9bcef9c45ef9076a2f48f0a7ff |
|
BLAKE2b-256 | dd2d0c20e1ec2272bf8d336ff82db1bf31b858059f9ac02e31d0eb3b732da715 |