Redis
Key-value операции с Redis
Redis — это open-source in-memory хранилище структур данных, используемое как распределённая key-value база данных, кэш и брокер сообщений. Redis поддерживает множество структур данных, включая строки, хэши, списки, множества и другие, что делает его очень гибким для самых разных сценариев.
Redis позволяет:
- Мгновенно сохранять и получать key-value данные: используйте Redis как быструю базу данных, кэш или хранилище сессий для высокой производительности.
- Работать с разными структурами данных: управляйте не только строками, но и списками, хэшами, множествами, отсортированными множествами, стримами и битовыми картами.
- Выполнять атомарные операции: безопасно изменяйте данные с помощью атомарных команд и транзакций.
- Использовать pub/sub messaging: применяйте функции издатель/подписчик Redis для обработки событий и обмена сообщениями в реальном времени.
- Задавать политики автоматического истечения: устанавливайте TTL для ключей при кэшировании и работе с данными, ограниченными по времени.
- Масштабироваться горизонтально: используйте Redis Cluster для шардирования, отказоустойчивости и масштабируемой нагрузки.
Интеграция Redis в AACFlow позволяет вашим AI-агентам подключаться к любому Redis-совместимому инстансу и выполнять операции с ключами, хэшами, списками и служебные команды. Вы можете строить воркфлоу, которые сохраняют, получают или изменяют данные в Redis, либо управлять кэшем приложения, сессиями или обменом сообщениями в реальном времени прямо из вашего рабочего пространства AACFlow.
Connect to any Redis instance to perform key-value, hash, list, и utility operations via a direct connection.
Получить значение of a key from Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The key to retrieve |
| Параметр | Тип | Описание |
|---|
key | string | The key that was retrieved |
value | string | The value of the key, or null if the key does not exist |
Установить value of a key in Redis с an optional expiration time in seconds.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The key to set |
value | string | Да | The value to store |
ex | number | Нет | Expiration time in seconds (optional) |
| Параметр | Тип | Описание |
|---|
key | string | The key that was set |
result | string | The result of the SET operation (typically "OK") |
Удалить key from Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The key to delete |
| Параметр | Тип | Описание |
|---|
key | string | The key that was deleted |
deletedCount | number | Number of keys deleted (0 if key did not exist, 1 if deleted) |
Список всех keys matching a pattern in Redis. Avoid using on large databases in production; use the Redis Command tool с SCAN для large key spaces.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
pattern | string | Нет | Pattern to match keys (default: * for all keys) |
| Параметр | Тип | Описание |
|---|
pattern | string | The pattern used to match keys |
keys | array | List of keys matching the pattern |
count | number | Number of keys found |
Выполнить a raw Redis command as a JSON array (e.g. [
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
command | string | Да | Redis command as a JSON array (e.g. ["SET", "key", "value"]) |
| Параметр | Тип | Описание |
|---|
command | string | The command that was executed |
result | json | The result of the command |
Set a field in a hash stored at a key in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The hash key |
field | string | Да | The field name within the hash |
value | string | Да | The value to set for the field |
| Параметр | Тип | Описание |
|---|
key | string | The hash key |
field | string | The field that was set |
result | number | Number of fields added (1 if new, 0 if updated) |
Получить значение of a field in a hash stored at a key in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The hash key |
field | string | Да | The field name to retrieve |
| Параметр | Тип | Описание |
|---|
key | string | The hash key |
field | string | The field that was retrieved |
value | string | The field value, or null if the field or key does not exist |
Получить все fields и values of a hash stored at a key in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The hash key |
| Параметр | Тип | Описание |
|---|
key | string | The hash key |
fields | object | All field-value pairs in the hash as a key-value object. Empty object if the key does not exist. |
fieldCount | number | Number of fields in the hash |
Удалить field from a hash stored at a key in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The hash key |
field | string | Да | The field name to delete |
| Параметр | Тип | Описание |
|---|
key | string | The hash key |
field | string | The field that was deleted |
deleted | number | Number of fields removed (1 if deleted, 0 if field did not exist) |
Increment the integer value of a key by one in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The key to increment |
| Параметр | Тип | Описание |
|---|
key | string | The key that was incremented |
value | number | The new value after increment |
Increment the integer value of a key by a given amount in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The key to increment |
increment | number | Да | Amount to increment by (negative to decrement) |
| Параметр | Тип | Описание |
|---|
key | string | The key that was incremented |
value | number | The new value after increment |
Set an expiration time (in seconds) on a key in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The key to set expiration on |
seconds | number | Да | Timeout in seconds |
| Параметр | Тип | Описание |
|---|
key | string | The key that expiration was set on |
result | number | 1 if the timeout was set, 0 if the key does not exist |
Получить remaining time to live (in seconds) of a key in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The key to check TTL for |
| Параметр | Тип | Описание |
|---|
key | string | The key that was checked |
ttl | number | Remaining TTL in seconds. Positive integer if TTL set, -1 if no expiration, -2 if key does not exist. |
Remove the expiration from a key in Redis, making it persist indefinitely.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The key to persist |
| Параметр | Тип | Описание |
|---|
key | string | The key that was persisted |
result | number | 1 if the expiration was removed, 0 if the key does not exist or has no expiration |
Prepend a value to a list stored at a key in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The list key |
value | string | Да | The value to prepend |
| Параметр | Тип | Описание |
|---|
key | string | The list key |
length | number | Length of the list after the push |
Append a value to the end of a list stored at a key in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The list key |
value | string | Да | The value to append |
| Параметр | Тип | Описание |
|---|
key | string | The list key |
length | number | Length of the list after the push |
Remove и return the first element of a list stored at a key in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The list key |
| Параметр | Тип | Описание |
|---|
key | string | The list key |
value | string | The removed element, or null if the list is empty |
Remove и return the last element of a list stored at a key in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The list key |
| Параметр | Тип | Описание |
|---|
key | string | The list key |
value | string | The removed element, or null if the list is empty |
Получить length of a list stored at a key in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The list key |
| Параметр | Тип | Описание |
|---|
key | string | The list key |
length | number | The length of the list, or 0 if the key does not exist |
Получить a range of elements from a list stored at a key in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The list key |
start | number | Да | Start index (0-based) |
stop | number | Да | Stop index (-1 for all elements) |
| Параметр | Тип | Описание |
|---|
key | string | The list key |
values | array | List elements in the specified range |
count | number | Number of elements returned |
Проверить if a key exists in Redis.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The key to check |
| Параметр | Тип | Описание |
|---|
key | string | The key that was checked |
exists | boolean | Произошла ли key exists (true) or not (false) |
Установить value of a key in Redis only if the key does not already exist.
| Параметр | Тип | Обязательный | Описание |
|---|
url | string | Да | Redis connection URL (e.g. redis://user:password@host:port) |
key | string | Да | The key to set |
value | string | Да | The value to store |
| Параметр | Тип | Описание |
|---|
key | string | The key that was set |
wasSet | boolean | Произошла ли key was set (true) or already existed (false) |