partitions_cache.py 472 Bytes
Newer Older
Luc Yriarte's avatar
Luc Yriarte committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from cachetools import TTLCache


class PartitionsCache:
    partitions_cache = TTLCache(maxsize=100, ttl=300)

    @staticmethod
    def get(data_partition_id: str):
        return PartitionsCache.partitions_cache.get(data_partition_id)

    @staticmethod
    def set(data_partition_id: str, partition_info):
        PartitionsCache.partitions_cache[data_partition_id] = partition_info

    @staticmethod
    def clear():
        PartitionsCache.partitions_cache.clear()