mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 09:50:15 +01:00
🧰 refactor: Default TTL for Cached Tools (#11033)
Some checks are pending
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Waiting to run
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Waiting to run
Publish `@librechat/client` to NPM / build-and-publish (push) Waiting to run
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Waiting to run
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Waiting to run
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions
Some checks are pending
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Waiting to run
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Waiting to run
Publish `@librechat/client` to NPM / build-and-publish (push) Waiting to run
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Waiting to run
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Waiting to run
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions
- Added `TWELVE_HOURS` constant to `Time` enum for better time management. - Updated `getCachedTools` function to set a default TTL of 12 hours if not specified in options.
This commit is contained in:
parent
41f815c037
commit
9dda857a59
2 changed files with 4 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
const { CacheKeys } = require('librechat-data-provider');
|
const { CacheKeys, Time } = require('librechat-data-provider');
|
||||||
const getLogStores = require('~/cache/getLogStores');
|
const getLogStores = require('~/cache/getLogStores');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -39,12 +39,12 @@ async function getCachedTools(options = {}) {
|
||||||
* @param {Object} options - Options for caching tools
|
* @param {Object} options - Options for caching tools
|
||||||
* @param {string} [options.userId] - User ID for user-specific MCP tools
|
* @param {string} [options.userId] - User ID for user-specific MCP tools
|
||||||
* @param {string} [options.serverName] - MCP server name for server-specific tools
|
* @param {string} [options.serverName] - MCP server name for server-specific tools
|
||||||
* @param {number} [options.ttl] - Time to live in milliseconds
|
* @param {number} [options.ttl] - Time to live in milliseconds (default: 12 hours)
|
||||||
* @returns {Promise<boolean>} Whether the operation was successful
|
* @returns {Promise<boolean>} Whether the operation was successful
|
||||||
*/
|
*/
|
||||||
async function setCachedTools(tools, options = {}) {
|
async function setCachedTools(tools, options = {}) {
|
||||||
const cache = getLogStores(CacheKeys.CONFIG_STORE);
|
const cache = getLogStores(CacheKeys.CONFIG_STORE);
|
||||||
const { userId, serverName, ttl } = options;
|
const { userId, serverName, ttl = Time.TWELVE_HOURS } = options;
|
||||||
|
|
||||||
// Cache by MCP server if specified (requires userId)
|
// Cache by MCP server if specified (requires userId)
|
||||||
if (serverName && userId) {
|
if (serverName && userId) {
|
||||||
|
|
|
||||||
|
|
@ -1239,6 +1239,7 @@ export enum InfiniteCollections {
|
||||||
*/
|
*/
|
||||||
export enum Time {
|
export enum Time {
|
||||||
ONE_DAY = 86400000,
|
ONE_DAY = 86400000,
|
||||||
|
TWELVE_HOURS = 43200000,
|
||||||
ONE_HOUR = 3600000,
|
ONE_HOUR = 3600000,
|
||||||
THIRTY_MINUTES = 1800000,
|
THIRTY_MINUTES = 1800000,
|
||||||
TEN_MINUTES = 600000,
|
TEN_MINUTES = 600000,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue