Created
August 29, 2011 15:52
-
-
Save espeed/1178694 to your computer and use it in GitHub Desktop.
Bulbs/Redis Caching Get Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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