def produce_cache_key(fun, *args, **kwargs):
    args_key = '_'.join(str(a) for a in args)
kwargs_key = '_'.join('%s%s' % (k, v) for k, v in list(kwargs.items()))
return '%s_%s_%s' % (id(fun), args_key, kwargs_key)
Data structure of memoization in db