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!

Metadata

Release files for momento 1.29.1

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.1
File Size Uploaded Provenance
momento-1.29.1.tar.gz 90.5 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 240.0 kB

Release files / momento-1.29.1.tar.gz

Download URL momento-1.29.1.tar.gz
Size 90.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a60ace778fe929c5dd75b8a235833e4c10c9ca6135426546f84e81e2dea592e3
BLAKE2b-256 checksum
How to use checksums
d29d3c685a0826d4dd8865d20e1e5a6b185a74c5ebe672574917885d080ef662
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.12.3 Linux/7.0.0-1017-azure

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

Download URL momento-1.29.1-py3-none-any.whl
Size 149.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e6a751a4122d1b1e0e99d1fcf4518061d3572ef44dcf10c9ee4d5f434a80383a
BLAKE2b-256 checksum
How to use checksums
ed7f98faef66bfa774b57f2a183e5e4664b164b203f270d978f02078a5ec5a52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.12.3 Linux/7.0.0-1017-azure

Security for momento 1.29.1

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.

Release history Release notifications | RSS feed

This release

1.29.1 This release

2 release files No provenance

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