mirror of
https://github.com/codl/forget
synced 2025-01-09 06:03:06 +01:00
whoops! fix imgproxy expiry time scale
This commit is contained in:
parent
5e1ce21c82
commit
0ecc9c25ca
@ -5,7 +5,7 @@ from flask import make_response, abort
|
|||||||
|
|
||||||
|
|
||||||
class ImgProxyCache(object):
|
class ImgProxyCache(object):
|
||||||
def __init__(self, redis_uri='redis://', timeout=1, expire=60*60*6,
|
def __init__(self, redis_uri='redis://', timeout=1, expire=60*60*24,
|
||||||
prefix='img_proxy'):
|
prefix='img_proxy'):
|
||||||
self.redis = redis.StrictRedis.from_url(redis_uri)
|
self.redis = redis.StrictRedis.from_url(redis_uri)
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
@ -24,8 +24,10 @@ class ImgProxyCache(object):
|
|||||||
if(resp.status_code != 200):
|
if(resp.status_code != 200):
|
||||||
return
|
return
|
||||||
mime = resp.headers.get('content-type', 'application/octet-stream')
|
mime = resp.headers.get('content-type', 'application/octet-stream')
|
||||||
self.redis.set(self.key('mime', url), mime, px=self.expire)
|
self.redis.set(self.key('mime', url),
|
||||||
self.redis.set(self.key('body', url), resp.content, px=self.expire)
|
mime, px=self.expire*1000)
|
||||||
|
self.redis.set(self.key('body', url),
|
||||||
|
resp.content, px=self.expire*1000)
|
||||||
|
|
||||||
def respond(self, url):
|
def respond(self, url):
|
||||||
x_imgproxy_cache = 'HIT'
|
x_imgproxy_cache = 'HIT'
|
||||||
|
Loading…
Reference in New Issue
Block a user