This commit is contained in:
Igor Lobanov
2023-10-26 22:38:31 +02:00
parent 1c49780cd4
commit c2cc428abe
64 changed files with 631 additions and 626 deletions

View File

@@ -1,10 +1,10 @@
import asyncio
import json
from base.redis import redis
from orm.shout import Shout
from resolvers.zine.load import load_shouts_by
import asyncio
import json
class SearchService:
lock = asyncio.Lock()
@@ -13,7 +13,7 @@ class SearchService:
@staticmethod
async def init(session):
async with SearchService.lock:
print('[search.service] did nothing')
print("[search.service] did nothing")
SearchService.cache = {}
@staticmethod
@@ -21,7 +21,12 @@ class SearchService:
cached = await redis.execute("GET", text)
if not cached:
async with SearchService.lock:
options = {"title": text, "body": text, "limit": limit, "offset": offset}
options = {
"title": text,
"body": text,
"limit": limit,
"offset": offset,
}
payload = await load_shouts_by(None, None, options)
await redis.execute("SET", text, json.dumps(payload))
return payload