mirror of https://gitlab.com/bashrc2/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]
|
||||
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:
|
||||
"""Store a webfinger endpoint in the cache
|
||||
"""
|
||||
|
|
|
@ -109,6 +109,7 @@ from announce import createAnnounce
|
|||
from announce import outboxAnnounce
|
||||
from content import addHtmlTags
|
||||
from media import removeMetaData
|
||||
from cache import expireCache
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -2940,6 +2941,12 @@ def runDaemon(projectVersion, \
|
|||
print('Creating actors cache')
|
||||
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')
|
||||
httpd.thrInboxQueue= \
|
||||
threadWithTrace(target=runInboxQueue, \
|
||||
|
|
2
inbox.py
2
inbox.py
|
@ -1037,7 +1037,7 @@ def restoreQueueItems(baseDir: str,queue: []) -> None:
|
|||
queue.append(os.path.join(queueDir, qfile))
|
||||
if len(queue)>0:
|
||||
print('Restored '+str(len(queue))+' inbox queue items')
|
||||
|
||||
|
||||
def runInboxQueue(projectVersion: str, \
|
||||
baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \
|
||||
cachedWebfingers: {},personCache: {},queue: [], \
|
||||
|
|
Loading…
Reference in New Issue