Skip to content

Commit 48883db

Browse files
hash the schema as the client side cache key
1 parent 3d5cd02 commit 48883db

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

redisvl/schema/validation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using dynamically generated Pydantic models.
66
"""
77

8+
import json
89
from typing import Any, Dict, List, Optional, Type, Union
910

1011
from jsonpath_ng import parse as jsonpath_parse
@@ -41,7 +42,7 @@ def get_model_for_schema(cls, schema: IndexSchema) -> Type[BaseModel]:
4142
A Pydantic model class that can validate data against the schema
4243
"""
4344
# Use schema identifier as cache key
44-
cache_key = schema.index.name
45+
cache_key = str(hash(json.dumps(schema.to_dict(), sort_keys=True).encode()))
4546

4647
if cache_key not in cls._model_cache:
4748
cls._model_cache[cache_key] = cls._create_model(schema)

0 commit comments

Comments
 (0)