Skip to main content
logo

project status project stability

Momento Client Library for Python

Momento Cache is a fast, simple, pay-as-you-go caching solution without any of the operational overhead required by traditional caching solutions. This repo contains the source code for the Momento client library for Python.

To get started with Momento you will need a Momento Auth Token. You can get one from the Momento Console.

Packages

The Momento Python SDK package is available on pypi: momento.

Prerequisites

Usage

Python 3.10 introduced the match statement, which allows for structural pattern matching on objects. If you are running python 3.10 or greater, here is a quickstart you can use in your own project:

from datetime import timedelta

from momento import CacheClient, Configurations, CredentialProvider
from momento.responses import CacheGet

cache_client = CacheClient(
    Configurations.Laptop.v1(), CredentialProvider.from_environment_variables_v2(), timedelta(seconds=60)
)

cache_client.create_cache("cache")
cache_client.set("cache", "my-key", "my-value")
get_response = cache_client.get("cache", "my-key")
match get_response:
    case CacheGet.Hit() as hit:
        print(f"Got value: {hit.value_string}")
    case _:
        print(f"Response was not a hit: {get_response}")

The above code uses structural pattern matching, a feature introduced in Python 3.10. Using a Python version less than 3.10? No problem. Here is the same example compatible across all versions of Python:

from datetime import timedelta

from momento import CacheClient, Configurations, CredentialProvider
from momento.responses import CacheGet

cache_client = CacheClient(
    configuration=Configurations.Laptop.v1(),
    credential_provider=CredentialProvider.from_environment_variables_v2(),
    default_ttl=timedelta(seconds=60),
)
cache_client.create_cache("cache")
cache_client.set("cache", "myKey", "myValue")
get_response = cache_client.get("cache", "myKey")
if isinstance(get_response, CacheGet.Hit):
    print(f"Got value: {get_response.value_string}")

Getting Started and Documentation

Documentation is available on the Momento Docs website.

Examples

Working example projects, with all required build configuration files, are available for both Python 3.10 and up and Python versions before 3.10:

Developing

If you are interested in contributing to the SDK, please see the CONTRIBUTING docs.


For more info, visit our website at https://gomomento.com!

Release files for momento 1.29.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for momento 1.29.0
File Size Uploaded
momento-1.29.0.tar.gz 90.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for momento 1.29.0
File Interpreter ABI Platform
momento-1.29.0-py3-none-any.whl Python 3 none any Details

Total release size: 240.1 kB

Release files / momento-1.29.0.tar.gz

Download URL momento-1.29.0.tar.gz
Size 90.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b43f881582e882fde262dff6a71b4cb312c312f0e9eb8576317fa98c761d1e7d
BLAKE2b-256 checksum
How to use checksums
4ee15e19af29e6b15ffcd2b93ae6624c6478999b0ffc50ac3bc19498d96f9fd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.12.3 Linux/6.17.0-1022-azure

Release files / momento-1.29.0-py3-none-any.whl

Download URL momento-1.29.0-py3-none-any.whl
Size 149.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
222337731b81d8b1ade4ade17bab5ff73778648cbfa95f27f1c86fe44d8b414b
BLAKE2b-256 checksum
How to use checksums
8fe40f888b6f4c2c2060365fb14077f1bbfc7af8f7ccd4d4ee9bf34fd02a00cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.12.3 Linux/6.17.0-1022-azure

Release history Release notifications | RSS feed

2.0.0

2 release files

This release

1.29.0 This release

2 release files

1.28.0

2 release files

1.25.0

2 release files

1.24.0

2 release files

1.23.5

2 release files

1.23.3

2 release files

1.23.2

2 release files

1.23.1

2 release files

1.23.0

2 release files

1.22.0

2 release files

1.21.1

2 release files

1.20.1

2 release files

1.19.1

2 release files

1.19.0

2 release files

1.18.2

2 release files

1.18.1

2 release files

1.17.0

2 release files

1.16.0

2 release files

1.14.1

2 release files

1.14.0

2 release files

1.13.2

2 release files

1.13.1

2 release files

1.12.0

2 release files

1.11.0

2 release files

1.10.2

2 release files

1.9.2

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.24.0

2 release files

0.23.0

2 release files

0.19.0

2 release files

0.17.0

2 release files

0.16.3

2 release files

0.16.2

2 release files

0.16.1

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page