Skip to content
Snippets Groups Projects
Commit 3aab4603 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

MultiCacheKeyService must be thread safe

parent d0fe3da9
Branches
No related tags found
No related merge requests found
import abc
import threading
from abc import ABC
from dataclasses import dataclass
from datetime import datetime
......@@ -14,11 +15,15 @@ class CacheEntry:
cachedData: Dict
lock = threading.Lock()
class MultiCacheKeyService(ABC):
def __init__(self):
self._cache = {}
def get_data(self, cacheKey: str, fetchIntervalInSeconds: int, settings: Dict) -> Dict:
with lock:
if cacheKey not in self._cache:
self._cache[cacheKey] = CacheEntry(cacheKey, fetchIntervalInSeconds, settings, 0, {})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment