# 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
     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
def redis_zaddbyscore():
    """ Increments multiple keys in a sorted set & returns them """

    return context.connections.redis.register_script("""
local zset = KEYS[1]
local min = ARGV[1]
local max = ARGV[2]
local offset = ARGV[3]
local count = ARGV[4]
local score = ARGV[5]

local data = redis.call('zrangebyscore', zset, min, max, 'LIMIT', offset, count)
for i, member in pairs(data) do
  redis.call('zadd', zset, score, member)
end

return data
  """)



# 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

     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
def redis_zaddbyscore():
    """ Increments multiple keys in a sorted set & returns them """

    return context.connections.redis.register_script("""
local zset = KEYS[1]
local min = ARGV[1]
local max = ARGV[2]
local offset = ARGV[3]
local count = ARGV[4]
local score = ARGV[5]

local data = redis.call('zrangebyscore', zset, min, max, 'LIMIT', offset, count)
for i, member in pairs(data) do
  redis.call('zadd', zset, score, member)
end

return data
  """)



@memoize