Add project files.

This commit is contained in:
Computerboer
2023-05-30 23:56:32 +02:00
parent 8df7abbf2a
commit e20f393223
317 changed files with 97059 additions and 0 deletions

32
config.py Normal file
View File

@@ -0,0 +1,32 @@
from datetime import datetime, timedelta
cache = {}
class Cache():
def get(key):
print('get key ' + key)
if key in cache:
cacheobj = cache[key]
if(cacheobj.isOlderThanHours(24)):
print('removing cacheobject ' + key)
del cache[key]
return None
print('returning cacheobject ' + key)
return cache[key]
def add(key, obj):
print('adding cacheobject ' + key)
cacheobj = CacheObj(key, obj)
cache[key] = cacheobj
class CacheObj:
def __init__(self, key, obj):
self.key = key
self.obj = obj
self.time=datetime.now()
def isOlderThanHours(self, hours):
print(f'checking time cacheobject {self.time} < {datetime.now() - timedelta(hours=hours)}')
return self.time < datetime.now() - timedelta(hours=hours)