29 lines
890 B
Python
29 lines
890 B
Python
import logging
|
|
from logging import Logger
|
|
from typing import Literal
|
|
|
|
from libbot.cache.classes import CacheMemcached, CacheRedis
|
|
from libbot.cache.manager import create_cache_client
|
|
from libbot.pycord.classes import PycordBot
|
|
|
|
logger: Logger = logging.getLogger(__name__)
|
|
|
|
|
|
class HoloBot(PycordBot):
|
|
cache: CacheMemcached | CacheRedis | None = None
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self._set_cache_engine()
|
|
|
|
def _set_cache_engine(self) -> None:
|
|
cache_type: Literal["redis", "memcached"] | None = self.config["cache"]["type"]
|
|
|
|
if "cache" in self.config and cache_type is not None:
|
|
self.cache = create_cache_client(
|
|
self.config,
|
|
cache_type,
|
|
prefix=self.config["cache"][cache_type]["prefix"],
|
|
default_ttl_seconds=3600,
|
|
)
|