Skip to content

Instantly share code, notes, and snippets.

@espeed
Created August 29, 2011 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save espeed/1178694 to your computer and use it in GitHub Desktop.
Save espeed/1178694 to your computer and use it in GitHub Desktop.
Bulbs/Redis Caching Get Example
import pickle
from redis import Redis
from bulbs.graph import Graph
# https://github.com/espeed/bulbs
# https://github.com/andymccurdy/redis-py
g = Graph()
redis = Redis()
def get(eid):
data = redis.get(eid)
if data:
vertex = pickle.loads(data)
else:
vertex = g.vertices.get(eid)
data = pickle.dumps(vertex)
redis.set(eid,data)
return vertex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment