def RedisCache(*args, **vars):

    locker.acquire()
    try:
        if not hasattr(RedisCache, 'redis_instance'):
            RedisCache.redis_instance = RedisClient(*args, **vars)
    finally:
        locker.release()
    return RedisCache.redis_instance
Usage example: put in models
dataset/ETHPy150Open uwdata/termite-data-server/web2py/gluon/contrib/redis_cache.py/RedisCache