GithubHelp home page GithubHelp logo

cprice404 / client-sdk-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from momentohq/client-sdk-python

0.0 0.0 0.0 337 KB

Official Python SDK for Momento Serverless Cache

License: Apache License 2.0

Shell 0.55% Python 98.58% Makefile 0.86%

client-sdk-python's Introduction

Momento client-sdk-python

⚠️ Experimental SDK ⚠️

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 🏃

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)

client-sdk-python's People

Contributors

bruuuuuuuce avatar cprice404 avatar eaddingtonwhite avatar gautamomento avatar kvcache avatar malandis avatar mjindalmotiv8 avatar pgautier404 avatar poppoerika avatar rlinehan avatar tylerburdsall avatar virratanasangpunth avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.