Commit 32398e6f authored by Yannick's avatar Yannick
Browse files

logging + cache extended to 1h

parent d330c770
Pipeline #44979 passed with stage
in 41 seconds
import logging
from os import environ
import uuid
from osdu_az.opendes.fake_partition_client import FakePartitionClient
from osdu_az.opendes.partition_client import PartitionClient
......@@ -26,12 +27,13 @@ PARTITION_ID = 'id'
class PartitionService:
partition_client = None
scope = ''
_id = str(uuid.uuid4())
@staticmethod
async def get_partition(data_partition_id: str) -> PartitionInfo:
partition_info = PartitionsCache.get(data_partition_id)
if partition_info is None:
_LOGGER.info(f'Partition info "{data_partition_id}" not cached => fetch it')
_LOGGER.info(f'[id {PartitionService._id}] Partition info "{data_partition_id}" not cached => fetch it')
partition_info = await PartitionService._partition_client().get_partition(data_partition_id)
if partition_info:
_LOGGER.info(f'PartitionService fetching partition info for "{data_partition_id}"')
......
import logging
from cachetools import TTLCache
import uuid
_LOGGER = logging.getLogger(__name__)
class PartitionsCache:
partitions_cache = TTLCache(maxsize=100, ttl=300)
partitions_cache = TTLCache(maxsize=100, ttl=3600)
_id = str(uuid.uuid4())
@staticmethod
def get(data_partition_id: str):
......@@ -13,7 +15,7 @@ class PartitionsCache:
@staticmethod
def set(data_partition_id: str, partition_info):
_LOGGER.info(f"set in partition cache {PartitionsCache} info from '{data_partition_id}'")
_LOGGER.info(f"[cache id {PartitionsCache._id}] set in partition cache info for '{data_partition_id}'")
PartitionsCache.partitions_cache[data_partition_id] = partition_info
@staticmethod
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment