@@ -167,6 +167,13 @@ def get_by_key(self, key: str) -> Optional[Dict[str, Any]]:
167167
168168 embedding_data = cache.get_by_key("embedcache:1234567890abcdef")
169169 """
170+ if self ._owns_redis_client is False and self ._redis_client is None :
171+ logger .warning (
172+ "You are using redis_client but you had initialised the EmbeddingCache with an async_redis_client only. "
173+ "If you intended to use async_redis_client, please use async aget(text, model_name) method of EmbeddingCache instead "
174+ "of get(text, model_name)."
175+ )
176+
170177 client = self ._get_redis_client ()
171178
172179 # Get all fields
@@ -202,6 +209,13 @@ def mget_by_keys(self, keys: List[str]) -> List[Optional[Dict[str, Any]]]:
202209 if not keys :
203210 return []
204211
212+ if self ._owns_redis_client is False and self ._redis_client is None :
213+ logger .warning (
214+ "You are using redis_client but you had initialised the EmbeddingCache with an async_redis_client only. "
215+ "If you intended to use async_redis_client, please use async amget(texts, model_name) method of EmbeddingCache instead "
216+ "of mget(texts, model_name)."
217+ )
218+
205219 client = self ._get_redis_client ()
206220
207221 with client .pipeline (transaction = False ) as pipeline :
@@ -283,6 +297,13 @@ def set(
283297 text , model_name , embedding , metadata
284298 )
285299
300+ if self ._owns_redis_client is False and self ._redis_client is None :
301+ logger .warning (
302+ "You are using redis_client but you had initialised the EmbeddingCache with an async_redis_client only. "
303+ "If you intended to use async_redis_client, please use async aset(text, model_name, embedding, metadata=None, ttl=None) "
304+ "method of EmbeddingCache instead of set(text, model_name, embedding, metadata=None, ttl=None)."
305+ )
306+
286307 # Store in Redis
287308 client = self ._get_redis_client ()
288309 client .hset (name = key , mapping = cache_entry ) # type: ignore
@@ -333,6 +354,13 @@ def mset(
333354 if not items :
334355 return []
335356
357+ if self ._owns_redis_client is False and self ._redis_client is None :
358+ logger .warning (
359+ "You are using redis_client but you had initialised the EmbeddingCache with an async_redis_client only. "
360+ "If you intended to use async_redis_client, please use async amset(items, ttl=None) method of EmbeddingCache instead "
361+ "of mset(items, ttl=None)."
362+ )
363+
336364 client = self ._get_redis_client ()
337365 keys = []
338366
0 commit comments