The SingleStoreDBSemanticCache uses SingleStore DB as a backend.
⚠️ Deprecation Warning: This class is pending deprecation. Users should migrate to SingleStoreSemanticCache in the langchain_singlestore package.
Key Configuration Options:
embedding (Embeddings): A text embedding model.cache_table_prefix (str, default: "cache_"): Prefix for the cache table name.search_threshold (float, default: 0.2): Minimum similarity score for a match.distance_strategy: Determines how distance is calculated. Options are DOT_PRODUCT (default) or EUCLIDEAN_DISTANCE.use_vector_index (bool, default: False): Toggles vector index usage (requires SingleStoreDB 8.5+).vector_size (int): Required if use_vector_index is True.host, user, password, port, database: Standard database connection parameters.
import langchain
from langchain_community.cache import SingleStoreDBSemanticCache
from langchain_openai import OpenAIEmbeddings
# Basic Usage
langchain.llm_cache = SingleStoreDBSemanticCache(
embedding=OpenAIEmbeddings(),
host="https://user:password@127.0.0.1:3306/database"
)
# Advanced Usage
langchain.llm_cache = SingleStoreDBSemanticCache(
embedding=OpenAIEmbeddings(),
use_vector_index=True,
host="127.0.0.1",
port=3306,
user="user",
password="password",
database="db",
table_name="my_custom_table",
pool_size=10,
timeout=60,
)