forked from indymedia/epicyon
Thread for cache expiry
parent
97799f1db2
commit
25b2f3210b
8
cache.py
8
cache.py
|
@ -65,6 +65,14 @@ def expirePersonCache(personCache: {}):
|
||||||
del personCache[personUrl]
|
del personCache[personUrl]
|
||||||
print(str(len(removals))+' actors were expired from the cache')
|
print(str(len(removals))+' actors were expired from the cache')
|
||||||
|
|
||||||
|
def expireCache(baseDir: str,personCache: {}):
|
||||||
|
"""Cache expiry thread
|
||||||
|
"""
|
||||||
|
while True:
|
||||||
|
# once per day
|
||||||
|
time.sleep(60*60*24)
|
||||||
|
expirePersonCache(basedir,personCache)
|
||||||
|
|
||||||
def storeWebfingerInCache(handle: str,wf,cachedWebfingers: {}) -> None:
|
def storeWebfingerInCache(handle: str,wf,cachedWebfingers: {}) -> None:
|
||||||
"""Store a webfinger endpoint in the cache
|
"""Store a webfinger endpoint in the cache
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -109,6 +109,7 @@ from announce import createAnnounce
|
||||||
from announce import outboxAnnounce
|
from announce import outboxAnnounce
|
||||||
from content import addHtmlTags
|
from content import addHtmlTags
|
||||||
from media import removeMetaData
|
from media import removeMetaData
|
||||||
|
from cache import expireCache
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -2940,6 +2941,12 @@ def runDaemon(projectVersion, \
|
||||||
print('Creating actors cache')
|
print('Creating actors cache')
|
||||||
os.mkdir(baseDir+'/cache/actors')
|
os.mkdir(baseDir+'/cache/actors')
|
||||||
|
|
||||||
|
print('Creating cache expiry thread')
|
||||||
|
httpd.thrCache= \
|
||||||
|
threadWithTrace(target=expireCache, \
|
||||||
|
args=(baseDir,httpd.personCache),daemon=True)
|
||||||
|
httpd.thrCache.start()
|
||||||
|
|
||||||
print('Creating inbox queue')
|
print('Creating inbox queue')
|
||||||
httpd.thrInboxQueue= \
|
httpd.thrInboxQueue= \
|
||||||
threadWithTrace(target=runInboxQueue, \
|
threadWithTrace(target=runInboxQueue, \
|
||||||
|
|
Loading…
Reference in New Issue