Unification of pagination, admins control and more

This commit is contained in:
2026-03-02 19:02:20 +07:00
parent 035170e46f
commit eab67ccfc1
13 changed files with 271 additions and 118 deletions

27
misc/redis.py Normal file
View File

@@ -0,0 +1,27 @@
import logging
from typing import Optional
from redis.asyncio import Redis
logger = logging.getLogger(__name__)
class RedisClient:
def __init__(self, r: Redis):
self.r = r
async def set_search_query(self, query_hash: str, q: str, ttl: int = 3600) -> bool:
try:
await self.r.set(f"search:{query_hash}", q, ex=ttl)
return True
except Exception as e:
logger.exception(e)
return False
async def get_search_query(self, query_hash: str) -> Optional[str]:
try:
res = await self.r.get(f"search:{query_hash}")
return res.decode()
except Exception as e:
logger.exception(e)
return None