This commit is contained in:
codey 2025-01-18 13:34:10 -05:00
parent 22ca3b9adc
commit dbaacf42a9
2 changed files with 7 additions and 8 deletions

View File

@ -49,7 +49,7 @@ class Cache:
artist=row['artist'],
song=row['song'],
lyrics=row['lyrics'],
src=f"{row['src']} (redis, id: {row['id']})",
src=f"{row['src']} (redis cache, id: {row['id']})",
confidence=row['confidence']
)
else:

View File

@ -6,10 +6,9 @@ import logging
import traceback
import json
import redis.asyncio as redis
from redis.commands.json.path import Path
from redis.commands.search.query import NumericFilter, Query
from redis.commands.search.query import Query
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
from redis.commands.search.field import TextField, NumericField, TagField
from redis.commands.search.field import TextField
from . import private
@ -27,8 +26,7 @@ class RedisCache:
"""
def __init__(self):
self.redis_pw = private.REDIS_PW
self.redis_client = redis.Redis(password=self.redis_pw)
self.redis_client = redis.Redis(password=private.REDIS_PW)
async def create_index(self):
"""Create Index"""
@ -39,10 +37,11 @@ class RedisCache:
TextField("$.src", as_name="src"),
TextField("$.lyrics", as_name="lyrics")
)
result = await self.redis_client.ft().create_index(schema, definition=IndexDefinition(prefix=["lyrics:"], index_type=IndexType.JSON))
result = await self.redis_client.ft().create_index(
schema, definition=IndexDefinition(prefix=["lyrics:"], index_type=IndexType.JSON))
if str(result) != "OK":
raise RedisException(f"Redis: Failed to create index: {result}")
except Exception as e:
except:
pass
async def search(self, **kwargs):