Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Python SDK for GhostDB Cache

Project description

Example SDK usage - Python

The below code covers a scenario for some back-end system where some process must fetch stock data from a database (e.g. MySQL) and process this data so that it is in a format required by the client to display, based on a ticker symbol and fetching and processing this data is expensive. Caching the data provides a way of speeding up this process.

from GhostDB.cache import Cache

cache = Cache("my_ghostdb.conf")

def getStockData(ticker_smbl):
    # Fetch data from cache
    stock_data = cache.get(ticker_smbl)

    if not stock_data:
        # Fetch from MySQL.
        # After any processing, we can 
        # assume our computed value is stored in
        # a variable called stock_data

        # Store result in cache
        cache.put(ticker_smbl, stock_data)
    return stock_data

return getStockData("AMZN")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ghostdb, version 0.8
Filename, size File type Python version Upload date Hashes
Filename, size ghostdb-0.8-py3-none-any.whl (7.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size ghostdb-0.8.tar.gz (6.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page