# _*_ coding : UTF-8 _*_
# @Time : 2025/02/04 15:20
# @UpdateTime : 2025/02/04 15:20
# @Author : sonder
# @File : cache.py
# @Software : PyCharm
# @Comment : 本程序
from typing import Optional, Any, List

from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel

from schemas.common import BaseResponse


class CacheMonitor(BaseModel):
    """
    缓存监控信息
    """
    model_config = ConfigDict(alias_generator=to_camel)

    command_stats: Optional[List] = Field(default=[], description='命令统计')
    db_size: Optional[int] = Field(default=None, description='Key数量')
    info: Optional[dict] = Field(default={}, description='Redis信息')


class CacheInfo(BaseModel):
    """
    缓存信息
    """
    model_config = ConfigDict(alias_generator=to_camel)

    cache_key: Optional[str] = Field(default=None, description='缓存键名')
    cache_name: Optional[str] = Field(default=None, description='缓存名称')
    cache_value: Optional[Any] = Field(default=None, description='缓存内容')
    remark: Optional[str] = Field(default=None, description='备注')


class GetCacheMonitorResponse(BaseResponse):
    """
    获取缓存监控信息响应
    """
    data: CacheMonitor = Field(default={}, description="缓存监控信息查询结果")


class GetCacheInfoResponse(BaseResponse):
    """
    获取缓存信息响应
    """
    data: List[CacheInfo] = Field(default=[], description="缓存信息查询结果")


class GetCacheKeysListResponse(BaseResponse):
    """
    获取缓存键名列表
    """
    data: List[str] = Field(default=[], description="缓存键名列表")
