Bug 63447 - 1/20 probability for cache clean
git-svn-id: svn://svn.office.custis.ru/3rdparty/viewvc.org/trunk@1411 6955db30-a419-402b-8a0d-67ecbb4d7f56remotes/github/custis
parent
3ec2c244a8
commit
575b4d8a49
|
@ -32,7 +32,7 @@ gac = {
|
||||||
'ga_always_require' : 0,
|
'ga_always_require' : 0,
|
||||||
'fof_sudo_server' : '',
|
'fof_sudo_server' : '',
|
||||||
'fof_sudo_cookie' : 'fof_sudo_id',
|
'fof_sudo_cookie' : 'fof_sudo_id',
|
||||||
'gc_probability' : 1000,
|
'gc_probability' : 20,
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in gac:
|
for i in gac:
|
||||||
|
@ -48,8 +48,8 @@ def cacheclean():
|
||||||
global gac
|
global gac
|
||||||
t = time.time()
|
t = time.time()
|
||||||
for fn in os.listdir(gac['cache_dir']):
|
for fn in os.listdir(gac['cache_dir']):
|
||||||
if t > os.stat(fn).st_mtime:
|
if t > os.stat(gac['cache_dir']+'/'+fn).st_mtime:
|
||||||
os.unlink(fn)
|
os.unlink(gac['cache_dir']+'/'+fn)
|
||||||
|
|
||||||
def cacheset(key, value, expire = 86400):
|
def cacheset(key, value, expire = 86400):
|
||||||
fn = cachefn(key)
|
fn = cachefn(key)
|
||||||
|
@ -183,7 +183,8 @@ def set_env_user(req, r_data):
|
||||||
|
|
||||||
def globalauth_handler(req, jar, v):
|
def globalauth_handler(req, jar, v):
|
||||||
global gac
|
global gac
|
||||||
if random.randint(1, gac['gc_probability']) == 1:
|
i = random.randint(1, gac['gc_probability'])
|
||||||
|
if i == 1:
|
||||||
cacheclean()
|
cacheclean()
|
||||||
r_id = jar.get(gac['cookie_name'], '')
|
r_id = jar.get(gac['cookie_name'], '')
|
||||||
if r_id:
|
if r_id:
|
||||||
|
|
Loading…
Reference in New Issue