hhpp.py
is a programming pattern library for world peace, LOL.
from hhpp.llive import fallbacks
def get_key_from_memcached(key):
return mc.get(key)
def get_key_from_redis(key):
value = rc.get(key)
if value is None:
fallbacks.abort()
return value
# Live migrate data from memcached to redis:
# If key not in redis, fallback to memcached. So that we can migrate cache
# from memcached to redis in the background without data loss.
value = fallbacks.Fallbacks()\
.chain(get_key_from_redis, 'test_key')\
.chain(get_key_from_memcached, 'test_key')\
.done()