Skip to main content

Python async client for Memcached

Project description

memcachio

docs codecov Latest Version in PyPI ci Supported Python versions


A pure python async Memcached client with 0 dependencies with support for:

  • All memcached commands
  • Memcached servers serving on TCP or Unix Domain Sockets
  • Memcached clusters
  • SSL transport
  • SASL Authentication
  • Connection reuse for multiple concurrent requests
  • Dynamically adjusted connection pooling
  • Auto discovery with AWS ElastiCache

Installation

To install memcachio:

$ pip install memcachio

Quick start

Single Node or Cluster client

import asyncio

from memcachio import Client


async def example() -> None:

    #: basic client
    raw_client = Client(("localhost", 11211))
    #: client that decodes the byte responses
    decoding_client = Client(("localhost", 11211), decode_responses=True)
    # or with a cluster
    # cluster_client = Client([("localhost", 11211), ("localhost", 11212)], decode_responses=True)

    await raw_client.flushall()
    await raw_client.set("foo", b"1")
    await raw_client.set("bar", b"2")

    assert 2 == await raw_client.incr("foo", 1)

    # use the raw client to get a value.
    # Note the mapping returned has byte keys
    assert (await raw_client.get("foo")).get(b"foo").value == b"2"

    # get the values with the decoding client and touch their expiry to be 1 second.
    # Note the mapping and the values are strings.
    gat_and_touch_many = await decoding_client.gat("foo", "bar", expiry=1)
    assert ["2", "2"] == [item.value for item in gat_and_touch_many.values()]

    await asyncio.sleep(1)

    assert {} == await decoding_client.get("foo", "bar")


asyncio.run(example())

See Client for detailed descriptions of available options when constructing a client.

Compatibility

memcachio is tested against memcached versions 1.6.x

Supported python versions

  • 3.10
  • 3.11
  • 3.12
  • 3.13
  • PyPy 3.10
  • PyPy 3.11

References

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

memcachio-0.4.2.tar.gz (50.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memcachio-0.4.2-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file memcachio-0.4.2.tar.gz.

File metadata

  • Download URL: memcachio-0.4.2.tar.gz
  • Upload date:
  • Size: 50.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for memcachio-0.4.2.tar.gz
Algorithm Hash digest
SHA256 acdcf1cac204d63ce689a7802503475681b716007cf6de2b02a9f96c53abbc9c
MD5 d565a9dd03f878e11fb4d1f1a377e239
BLAKE2b-256 1944b2c93d2d5630f01d2c5db38cf8be237547995ffd9f1b3ea4c0096d7b3494

See more details on using hashes here.

Provenance

The following attestation bundles were made for memcachio-0.4.2.tar.gz:

Publisher: main.yml on alisaifee/memcachio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file memcachio-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: memcachio-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for memcachio-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4f78d2becd1b19cc2621103b3d1c4560f7520193125071959d3f911f9399e9cb
MD5 b96b270f75c40dfe8cb4de60fe9ae6e0
BLAKE2b-256 d2b315b9803edfa9c64bab0ad0e26d6b1214952d28db3a8ee9c2ca28a1e56cb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for memcachio-0.4.2-py3-none-any.whl:

Publisher: main.yml on alisaifee/memcachio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page