import redis from redis.lock import Lock from apollo_clear_notifications.constants import APP_NAME, REDIS_LOCK_TTL def get_key(key: str) -> str: """Compose a Redis key. Args: key (str): Key. Returns: str: Complete key constructed by concatenated prefix + key. """ return f'{APP_NAME}/{key}' def get_redis_lock(redis_client: redis.StrictRedis) -> Lock: """Get redis lock""" return redis_client.lock(get_key('lock'), timeout=REDIS_LOCK_TTL)