EnkaNetwork.py/enkanetwork/cache.py

13 lines
296 B
Python
Raw Normal View History

2022-08-02 17:37:24 +00:00
import json
from cachetools import TTLCache
class Cache:
def __init__(self, maxsize, ttl):
self.cache = TTLCache(maxsize, ttl)
def get(self, key):
return json.loads(self.cache.get(key))
def set(self, key, value):
self.cache[key] = json.dumps(value)