Skip to content

layzerar/hhpp.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Build Status Coverage Status

hhpp.py is a programming pattern library for world peace, LOL.

General Patterns

Fallback processing chain

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()

About

Happy Hacking Programming Patterns

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages