librelist archives

« back to archive

[flask] flask cache redis server connection timeout

[flask] flask cache redis server connection timeout

From:
Heejoon Lee
Date:
2014-12-03 @ 09:37
Hi,

I am trying to use flask cache through ElastiCache Redis.

But I cannot find connection timeout setting in flask cache.
(here, connection timeout means Redis Server connection timeout from flask)

My cache configuration is as followings,












*    # Configure cache    cache_config = app.config.get('CACHE', {})    if
cache_config['CACHE_TYPE'] == 'redis':        cache.init_app(app, config =
{            'CACHE_TYPE': cache_config['CACHE_TYPE']
'CACHE_REDIS_HOST': cache_config['CACHE_REDIS_HOST'],
'CACHE_REDIS_PORT': cache_config['CACHE_REDIS_PORT'],
'CACHE_REDIS_URL': cache_config['CACHE_REDIS_URL']        })    else: #
this is for testing server        cache.init_app(app, config = {
'CACHE_TYPE': cache_config['CACHE_TYPE'] # here is simple        })*

This is cache.py







*  from flask import request   from flask.ext.cache import Cache   cache =
Cache()  def make_cache_key(*args, **kwargs):      path = request.path
args = str(hash(frozenset(request.args.items())))      return (path +
args).encode('utf-8')*


In case redis server is crashed, connection timeout should be needed.
But there is no parameter or configuration about that.
(Otherwise if redis server is crashed, then flask will not connect to Redis
Server?)

How can I set connection timeout?

Thanks a lot.

回复: [flask] flask cache redis server connection timeout

From:
linnchord gao
Date:
2014-12-04 @ 08:05
In my project, do not need that.

If you really care about this, you may read this page.


http://stackoverflow.com/questions/23930125/how-to-set-the-redis-timeout-waiting-for-the-response-with-pipeline-in-redis-py


--  
linnchord gao
已使用 Sparrow (http://www.sparrowmailapp.com/?sig)


在 2014年12月3日 星期三,17:37,Heejoon Lee 写道:

> Hi,
>  
> I am trying to use flask cache through ElastiCache Redis.
>  
> But I cannot find connection timeout setting in flask cache.
> (here, connection timeout means Redis Server connection timeout from flask)
>  
> My cache configuration is as followings,
>     # Configure cache
>     cache_config = app.config.get('CACHE', {})
>     if cache_config['CACHE_TYPE'] == 'redis':
>         cache.init_app(app, config = {
>             'CACHE_TYPE': cache_config['CACHE_TYPE']
>             'CACHE_REDIS_HOST': cache_config['CACHE_REDIS_HOST'],
>             'CACHE_REDIS_PORT': cache_config['CACHE_REDIS_PORT'],
>             'CACHE_REDIS_URL': cache_config['CACHE_REDIS_URL']
>         })
>     else: # this is for testing server
>  ? ?      cache.init_app(app, config = {
>             'CACHE_TYPE': cache_config['CACHE_TYPE'] # here is simple
>         })
>  
> This is cache.py
>   from flask import request  
>   from flask.ext.cache import Cache  
>   cache = Cache()
>  
>   def make_cache_key(*args, **kwargs):
>       path = request.path
>       args = str(hash(frozenset(request.args.items())))
>       return (path + args).encode('utf-8')
>  
>  
> In case redis server is crashed, connection timeout should be needed.
> But there is no parameter or configuration about that.
> (Otherwise if redis server is crashed, then flask will not connect to 
Redis Server?)
>  
> How can I set connection timeout?
>  
> Thanks a lot.
>  
>   
>  
>  
>  

Re: 回复: [flask] flask cache redis server conne

From:
Heejoon Lee
Date:
2014-12-06 @ 11:50
Hi linnchord gao

Thank you for your replying.

Heejoon Lee

On Thu, Dec 4, 2014 at 5:05 PM, linnchord gao <linnchord@163.com> wrote:

> In my project, do not need that.
>
> If you really care about this, you may read this page.
>
>
> 
http://stackoverflow.com/questions/23930125/how-to-set-the-redis-timeout-waiting-for-the-response-with-pipeline-in-redis-py
>
>
> --
> linnchord gao
> 已使用 Sparrow <http://www.sparrowmailapp.com/?sig>
>
> 在 2014年12月3日 星期三,17:37,Heejoon Lee 写道:
>
> Hi,
>
> I am trying to use flask cache through ElastiCache Redis.
>
> But I cannot find connection timeout setting in flask cache.
> (here, connection timeout means Redis Server connection timeout from flask)
>
> My cache configuration is as followings,
>
>
>
>
>
>
>
>
>
>
>
>
> *    # Configure cache    cache_config = app.config.get('CACHE', {})    if
> cache_config['CACHE_TYPE'] == 'redis':        cache.init_app(app, config =
> {            'CACHE_TYPE': cache_config['CACHE_TYPE']
> 'CACHE_REDIS_HOST': cache_config['CACHE_REDIS_HOST'],
> 'CACHE_REDIS_PORT': cache_config['CACHE_REDIS_PORT'],&n bsp;
> 'CACHE_REDIS_URL': cache_config['CACHE_REDIS_URL']        })    else: #
> this is for testing server ? ?      cache.init_app(app, config =
> {            'CACHE_TYPE': cache_config['CACHE_TYPE'] # here is
> simple        })*
>
> This is cache.py
>
>
>
>
>
>
>
> *  from flask import request   from flask.ext.cache import Cache   cache =
> Cache()  def make_cache_key(*args, **kwargs):      path = request.path
> args = str(hash(frozenset(request.args.items())))      return (path +
> args).encode('utf-8')*
>
>
> In case redis server is crashed, connection timeout should be needed.
> But there is no parameter or configuration about that.
> (Otherwise if redis server is crashed, then flask will not connect to
> Redis Server?)
>
> How can I set connection timeout?
>
> < /div>
> Thanks a lot.
>
>
>
>
>
>
>