You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

34 lines
666 B

  1. from contextlib import contextmanager
  2. try:
  3. import hiredis
  4. HIREDIS_AVAILABLE = True
  5. except ImportError:
  6. HIREDIS_AVAILABLE = False
  7. def from_url(url, db=None, **kwargs):
  8. """
  9. Returns an active Redis client generated from the given database URL.
  10. Will attempt to extract the database id from the path url fragment, if
  11. none is provided.
  12. """
  13. from redis.client import Redis
  14. return Redis.from_url(url, db, **kwargs)
  15. @contextmanager
  16. def pipeline(redis_obj):
  17. p = redis_obj.pipeline()
  18. yield p
  19. p.execute()
  20. class dummy(object):
  21. """
  22. Instances of this class can be used as an attribute container.
  23. """
  24. pass