littlefish/redisutil.py
def init(app):
    """
    Initialise this library.  The following config variables need to be in your Flask config:

    REDIS_HOST: The host of the Redis server
    REDIS_PORT: The port of the Redis server
    REDIS_PASSWORD: The password used to connect to Redis or None
    REDIS_GLOBAL_KEY_PREFIX: A short string unique to your application i.e. 'MYAPP'.  This will be turned into
                             a prefix like '~~MYAPP~~:' and will be used to allow multiple applications to share
                             a single redis server
    REDIS_LOCK_TIMEOUT: An integer with the number of seconds to wait before automatically releasing a lock.
                        A good number is 60 * 5 for 5 minutes.  This stops locks from being held indefinitely
                        if something goes wrong, but bear in mind this can also cause concurrency issues if
                        you ave a locking process that takes longer than this timeout!
    """
    global connection, LOCK_TIMEOUT, GLOBAL_KEY_PREFIX

    host = app.config['REDIS_HOST']
    port = app.config['REDIS_PORT']
    password = app.config['REDIS_PASSWORD']
    
    GLOBAL_KEY_PREFIX = '~~{}~~:'.format(app.config['REDIS_GLOBAL_KEY_PREFIX'])
    LOCK_TIMEOUT = app.config['REDIS_LOCK_TIMEOUT']

    connection = redis.StrictRedis(host=host, port=port, password=password)
def init(app):
    """
    Initialise this library.  The following config variables need to be in your Flask config:

    REDIS_HOST: The host of the Redis server
    REDIS_PORT: The port of the Redis server
    REDIS_PASSWORD: The password used to connect to Redis or None
    REDIS_GLOBAL_KEY_PREFIX: A short string unique to your application i.e. 'MYAPP'.  This will be turned into
                             a prefix like '~~MYAPP~~:' and will be used to allow multiple applications to share
                             a single redis server
    REDIS_LOCK_TIMEOUT: An integer with the number of seconds to wait before automatically releasing a lock.
                        A good number is 60 * 5 for 5 minutes.  This stops locks from being held indefinitely
                        if something goes wrong, but bear in mind this can also cause concurrency issues if
                        you ave a locking process that takes longer than this timeout!
    """
    global connection, LOCK_TIMEOUT, GLOBAL_KEY_PREFIX

    host = app.config['REDIS_HOST']
    port = app.config['REDIS_PORT']
    password = app.config['REDIS_PASSWORD']
    
    GLOBAL_KEY_PREFIX = '~~{}~~:'.format(app.config['REDIS_GLOBAL_KEY_PREFIX'])
    LOCK_TIMEOUT = app.config['REDIS_LOCK_TIMEOUT']

    connection = redis.StrictRedis(host=host, port=port, password=password)
Initialise this library.  The following config variables need to be in your Flask config:

    REDIS_HOST: The host of the Redis server
    REDIS_PORT: The port of the Redis server
    REDIS_PASSWORD: The password used to connect to Redis or None
    REDIS_GLOBAL_KEY_PREFIX: A short string unique to your application i.e. 'MYAPP'.  This will be turned into
                             a prefix like '~~MYAPP~~:' and will be used to allow multiple applications to share
                             a single redis server
    REDIS_LOCK_TIMEOUT: An integer with the number of seconds to wait before automatically releasing a lock.
                        A good number is 60 * 5 for 5 minutes.  This stops locks from being held indefinitely
                        if something goes wrong, but bear in mind this can also cause concurrency issues if
                        you ave a locking process that takes longer than this timeout!