Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A simple key-value MySQL store for small chunks of arbitrary data (strings, objects, ...).
Python
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
INSTALL.md
LICENSE
README.md
TODO
make_sql_cache.py
setup.py
sql_cache.py
test.py

README.md

A simple key-value MySQL store for small chunks of arbitrary data (strings, objects).

Here is an example of usage:

import sql_cache

# setup the database
sql_cache.set_DB(db='db', user='user', passwd='passwd') 

# setup cache size
sql_cache.MAX_SIZE = 10000

# make the cache table, drop it if it already exists
sql_cache.make_sql_table(drop=True)

# set some key value pairs
sql_cache.set('query_1', [1,2,3])
sql_cache.set('query_2', 'a string', sticky=True)
sql_cache.set('query_3', {'a':1, 'b':2, 'c':3})

# returns {'a':1, 'b':2, 'c':3}
print sql_cache.get('query_3')

# returns 'a string'
print sql_cache.get('query_2')

# clears the entire but not the sticky values
sql_cache.clear(also_sticky=False)

# returns None
print sql_cache.get('query_1')

# returns 'a string'
print sql_cache.get('query_2')
Something went wrong with that request. Please try again.