langchain_community.storage.upstash_redis.UpstashRedisStore¶

class langchain_community.storage.upstash_redis.UpstashRedisStore(*, client: Any = None, url: Optional[str] = None, token: Optional[str] = None, ttl: Optional[int] = None, namespace: Optional[str] = None)[source]¶

[Deprecated] BaseStore implementation using Upstash Redis as the underlying store to store strings.

Deprecated in favor of the more generic UpstashRedisByteStore.

Notes

Deprecated since version 0.0.1: Use UpstashRedisByteStore instead.

Initialize the UpstashRedisStore with HTTP API.

Must provide either an Upstash Redis client or a url.

Parameters
  • client (Any) – An Upstash Redis instance

  • url (Optional[str]) – UPSTASH_REDIS_REST_URL

  • token (Optional[str]) – UPSTASH_REDIS_REST_TOKEN

  • ttl (Optional[int]) – time to expire keys in seconds if provided, if None keys will never expire

  • namespace (Optional[str]) – if provided, all keys will be prefixed with this namespace

Methods

__init__(*[, client, url, token, ttl, namespace])

Initialize the UpstashRedisStore with HTTP API.

amdelete(keys)

Delete the given keys and their associated values.

amget(keys)

Get the values associated with the given keys.

amset(key_value_pairs)

Set the values for the given keys.

ayield_keys(*[, prefix])

Get an iterator over keys that match the given prefix.

mdelete(keys)

Delete the given keys.

mget(keys)

Get the values associated with the given keys.

mset(key_value_pairs)

Set the given key-value pairs.

yield_keys(*[, prefix])

Yield keys in the store.

__init__(*, client: Any = None, url: Optional[str] = None, token: Optional[str] = None, ttl: Optional[int] = None, namespace: Optional[str] = None) None¶

Initialize the UpstashRedisStore with HTTP API.

Must provide either an Upstash Redis client or a url.

Parameters
  • client (Any) – An Upstash Redis instance

  • url (Optional[str]) – UPSTASH_REDIS_REST_URL

  • token (Optional[str]) – UPSTASH_REDIS_REST_TOKEN

  • ttl (Optional[int]) – time to expire keys in seconds if provided, if None keys will never expire

  • namespace (Optional[str]) – if provided, all keys will be prefixed with this namespace

Return type

None

async amdelete(keys: Sequence[K]) None¶

Delete the given keys and their associated values.

Parameters

keys (Sequence[K]) – A sequence of keys to delete.

Return type

None

async amget(keys: Sequence[K]) List[Optional[V]]¶

Get the values associated with the given keys.

Parameters

keys (Sequence[K]) – A sequence of keys.

Returns

A sequence of optional values associated with the keys. If a key is not found, the corresponding value will be None.

Return type

List[Optional[V]]

async amset(key_value_pairs: Sequence[Tuple[K, V]]) None¶

Set the values for the given keys.

Parameters

key_value_pairs (Sequence[Tuple[K, V]]) – A sequence of key-value pairs.

Return type

None

async ayield_keys(*, prefix: Optional[str] = None) Union[AsyncIterator[K], AsyncIterator[str]]¶

Get an iterator over keys that match the given prefix.

Parameters

prefix (str) – The prefix to match.

Returns

An iterator over keys that match the given prefix.

This method is allowed to return an iterator over either K or str depending on what makes more sense for the given store.

Return type

Iterator[K | str]

mdelete(keys: Sequence[str]) None¶

Delete the given keys.

Parameters

keys (Sequence[str]) –

Return type

None

mget(keys: Sequence[str]) List[Optional[str]]¶

Get the values associated with the given keys.

Parameters

keys (Sequence[str]) –

Return type

List[Optional[str]]

mset(key_value_pairs: Sequence[Tuple[str, str]]) None¶

Set the given key-value pairs.

Parameters

key_value_pairs (Sequence[Tuple[str, str]]) –

Return type

None

yield_keys(*, prefix: Optional[str] = None) Iterator[str]¶

Yield keys in the store.

Parameters

prefix (Optional[str]) –

Return type

Iterator[str]