# Path: mrq/utils.py
# def memoize(f):
#     """ Memoization decorator for a function taking one or more arguments. """
#     class memodict(dict):
# 
#         def __getitem__(self, *key):
#             return dict.__getitem__(self, key)
# 
#         def __missing__(self, key):
#             ret = self[key] = f(*key)
#             return ret
# 
#     return memodict().__getitem__


from future.builtins import range
from .utils import memoize
from . import context


def redis_key(name, *args):
  prefix = context.get_current_config()["redis_prefix"]
  if name == "known_subqueues":
    return "%s:ksq:%s" % (prefix, args[0].root_id)
  elif name == "queue":
     return "%s:q:%s" % (prefix, args[0].id)
  elif name == "started_jobs":
    return "%s:s:started" % prefix
  elif name == "paused_queues":
    return "%s:s:paused" % prefix
  elif name == "notify":
     return "%s:notify:%s" % (prefix, args[0].root_id)



# Path: mrq/utils.py
# def memoize(f):
#     """ Memoization decorator for a function taking one or more arguments. """
#     class memodict(dict):
# 
#         def __getitem__(self, *key):
#             return dict.__getitem__(self, key)
# 
#         def __missing__(self, key):
#             ret = self[key] = f(*key)
#             return ret
# 
#     return memodict().__getitem__


# Path: mrq/redishelpers.py
from future.builtins import range
from .utils import memoize
from . import context



def redis_key(name, *args):
  prefix = context.get_current_config()["redis_prefix"]
  if name == "known_subqueues":
    return "%s:ksq:%s" % (prefix, args[0].root_id)
  elif name == "queue":
     return "%s:q:%s" % (prefix, args[0].id)
  elif name == "started_jobs":
    return "%s:s:started" % prefix
  elif name == "paused_queues":
    return "%s:s:paused" % prefix
  elif name == "notify":
     return "%s:notify:%s" % (prefix, args[0].root_id)



@memoize