Skip to main content

SDK for Momento

Project description

Momento client-sdk-python

:warning: Experimental SDK :warning:

Python SDK for Momento is experimental and under active development. There could be non-backward compatible changes or removal in the future. Please be aware that you may need to update your source code with the current version of the SDK when its version gets upgraded.



Python SDK for Momento, a serverless cache that automatically scales without any of the operational overhead required by traditional caching solutions.


Getting Started :running:

Requirements

  • Python 3.7 or above is required
  • A Momento Auth Token is required, you can generate one using the Momento CLI

Installing Momento and Running the Example

Check out our Python SDK example!


Using Momento

import os
from momento import simple_cache_client as scc

# Initializing Momento
_MOMENTO_AUTH_TOKEN = os.getenv('MOMENTO_AUTH_TOKEN')
_ITEM_DEFAULT_TTL_SECONDS = 60
with scc.SimpleCacheClient(_MOMENTO_AUTH_TOKEN, _ITEM_DEFAULT_TTL_SECONDS) as cache_client:
    # Creating a cache named "cache"
    _CACHE_NAME = 'cache'
    cache_client.create_cache(_CACHE_NAME)

    # Sets key with default TTL and get value with that key
    _KEY = 'MyKey'
    _VALUE = 'MyValue'
    cache_client.set(_CACHE_NAME, _KEY, _VALUE)
    get_resp = cache_client.get(_CACHE_NAME, _KEY)
    print(f'Looked up Value: {str(get_resp.value())}')

    # Sets key with TTL of 5 seconds
    cache_client.set(_CACHE_NAME, _KEY, _VALUE, 5)

    # Permanently deletes cache
    cache_client.delete_cache(_CACHE_NAME)

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

momento-0.16.3.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

momento-0.16.3-py3-none-any.whl (37.8 kB view details)

Uploaded Python 3

File details

Details for the file momento-0.16.3.tar.gz.

File metadata

  • Download URL: momento-0.16.3.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1022-azure

File hashes

Hashes for momento-0.16.3.tar.gz
Algorithm Hash digest
SHA256 5a9d30e1cc06d51625a99d7616ee229c9eb9524e5ec05618a59815274fe97659
MD5 16b65cbc97576c9f1868bf666a7d1c81
BLAKE2b-256 c448d0cf83bf7a11b3f7c58202049121288bc95062ce075e504d454891f63820

See more details on using hashes here.

File details

Details for the file momento-0.16.3-py3-none-any.whl.

File metadata

  • Download URL: momento-0.16.3-py3-none-any.whl
  • Upload date:
  • Size: 37.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1022-azure

File hashes

Hashes for momento-0.16.3-py3-none-any.whl
Algorithm Hash digest
SHA256 11eb657fcb2fc3bdf1db7b2ef01317f718bae273a0c0fd4911edf4f28820fbeb
MD5 6229536b9403d68e7b1209eefb70a3dc
BLAKE2b-256 380db545e7d59f7c0abd69a788c279c9dd838040dbe494cf3daac6c767ccf0bc

See more details on using hashes here.

Supported by

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