from typing import Generic, NamedTuple

from gallery.util import TimeUnit

from .api import API, Api


class CachePreset(NamedTuple):
    ttl: int = TimeUnit.HOUR
    alias: str = "redis"


DEFAULT_CACHE_PRESET = CachePreset()


class CachedApi(Api, Generic[API]):
    CACHE_KEY: str

    def __init__(self, api: API):
        self._api = api

    @property
    def provider(self) -> str:
        return self._api.provider
