# SingleStoreDBSemanticCache

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/cache/SingleStoreDBSemanticCache)

Cache that uses SingleStore DB as a backend

## Signature

```python
SingleStoreDBSemanticCache(
    self,
    embedding: Embeddings,
    *,
    cache_table_prefix: str = 'cache_',
    search_threshold: float = 0.2,
    **kwargs: Any = {},
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `embedding` | `Embeddings` | Yes | A text embedding model. |
| `cache_table_prefix` | `str` | No | Prefix for the cache table name. Defaults to "cache_". (default: `'cache_'`) |
| `search_threshold` | `float` | No | The minimum similarity score for a search result to be considered a match. Defaults to 0.2. (default: `0.2`) |
| `Following arguments pertrain to the SingleStoreDB vector store` | `unknown` | Yes |  |
| `distance_strategy` | `DistanceStrategy` | Yes |  Determines the strategy employed for calculating the distance between vectors in the embedding space. Defaults to DOT_PRODUCT. Available options are: - DOT_PRODUCT: Computes the scalar product of two vectors.     This is the default behavior - EUCLIDEAN_DISTANCE: Computes the Euclidean distance between     two vectors. This metric considers the geometric distance in     the vector space, and might be more suitable for embeddings     that rely on spatial relationships. This metric is not     compatible with the WEIGHTED_SUM search strategy. |
| `content_field` | `str` | Yes | Specifies the field to store the content. Defaults to "content". |
| `metadata_field` | `str` | Yes | Specifies the field to store metadata. Defaults to "metadata". |
| `vector_field` | `str` | Yes | Specifies the field to store the vector. Defaults to "vector". |
| `id_field` | `str` | Yes | Specifies the field to store the id. Defaults to "id". |
| `use_vector_index` | `bool` | Yes | Toggles the use of a vector index. Works only with SingleStoreDB 8.5 or later. Defaults to False. If set to True, vector_size parameter is required to be set to a proper value. |
| `vector_index_name` | `str` | Yes | Specifies the name of the vector index. Defaults to empty. Will be ignored if use_vector_index is set to False. |
| `vector_index_options` | `dict` | Yes | Specifies the options for the vector index. Defaults to {}. Will be ignored if use_vector_index is set to False. The options are: index_type (str, optional): Specifies the type of the index.     Defaults to IVF_PQFS. For more options, please refer to the SingleStoreDB documentation: https://docs.singlestore.com/cloud/reference/sql-reference/vector-functions/vector-indexing/ |
| `vector_size` | `int` | Yes | Specifies the size of the vector. Defaults to 1536. Required if use_vector_index is set to True. Should be set to the same value as the size of the vectors stored in the vector_field. |
| `Following arguments pertain to the connection pool` | `unknown` | Yes |  |
| `pool_size` | `int` | Yes | Determines the number of active connections in the pool. Defaults to 5. |
| `max_overflow` | `int` | Yes | Determines the maximum number of connections allowed beyond the pool_size. Defaults to 10. |
| `timeout` | `float` | Yes | Specifies the maximum wait time in seconds for establishing a connection. Defaults to 30. |
| `Following arguments pertain to the database connection` | `unknown` | Yes |  |
| `host` | `str` | Yes | Specifies the hostname, IP address, or URL for the database connection. The default scheme is "mysql". |
| `user` | `str` | Yes | Database username. |
| `password` | `str` | Yes | Database password. |
| `port` | `int` | Yes | Database port. Defaults to 3306 for non-HTTP connections, 80 for HTTP connections, and 443 for HTTPS connections. |
| `database` | `str` | Yes | Database name. |
| `database connection` | `unknown` | Yes |  |
| `pure_python` | `bool` | Yes | Toggles the connector mode. If True, operates in pure Python mode. |
| `local_infile` | `bool` | Yes | Allows local file uploads. |
| `charset` | `str` | Yes | Specifies the character set for string values. |
| `ssl_key` | `str` | Yes | Specifies the path of the file containing the SSL key. |
| `ssl_cert` | `str` | Yes | Specifies the path of the file containing the SSL certificate. |
| `ssl_ca` | `str` | Yes | Specifies the path of the file containing the SSL certificate authority. |
| `ssl_cipher` | `str` | Yes | Sets the SSL cipher list. |
| `ssl_disabled` | `bool` | Yes | Disables SSL usage. |
| `ssl_verify_cert` | `bool` | Yes | Verifies the server's certificate. Automatically enabled if ``ssl_ca`` is specified. |
| `ssl_verify_identity` | `bool` | Yes | Verifies the server's identity. |
| `conv` | `dict[int, Callable]` | Yes | A dictionary of data conversion functions. |
| `credential_type` | `str` | Yes | Specifies the type of authentication to use: auth.PASSWORD, auth.JWT, or auth.BROWSER_SSO. |
| `autocommit` | `bool` | Yes | Enables autocommits. |
| `results_type` | `str` | Yes | Determines the structure of the query results: tuples, namedtuples, dicts. |
| `results_format` | `str` | Yes | Deprecated. This option has been renamed to results_type. |

## Extends

- `BaseCache`

## Constructors

```python
__init__(
    self,
    embedding: Embeddings,
    *,
    cache_table_prefix: str = 'cache_',
    search_threshold: float = 0.2,
    **kwargs: Any = {},
)
```

| Name | Type |
|------|------|
| `embedding` | `Embeddings` |
| `cache_table_prefix` | `str` |
| `search_threshold` | `float` |


## Properties

- `embedding`
- `cache_table_prefix`
- `search_threshold`
- `connection_kwargs`

## Methods

- [`lookup()`](https://reference.langchain.com/python/langchain-community/cache/SingleStoreDBSemanticCache/lookup)
- [`update()`](https://reference.langchain.com/python/langchain-community/cache/SingleStoreDBSemanticCache/update)
- [`clear()`](https://reference.langchain.com/python/langchain-community/cache/SingleStoreDBSemanticCache/clear)

## ⚠️ Deprecated

Deprecated since version 0.3.22.

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/a6a6079511ac8a5c1293337f88096b8641562e77/libs/community/langchain_community/cache.py#L2050)