Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
Signed-off-by: sarthakjdev <[email protected]>
  • Loading branch information
sarthakjdev committed Jul 14, 2024
1 parent a42d511 commit 087c668
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions apps/wapi-ai-chatbot/src/utils/cache.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { caching } from 'cache-manager'

const cacheStore = caching({
store: 'memory'
store: 'memory'
})

export async function cacheData(params: { key: string; data: any; ttl?: number }) {

Check warning on line 7 in apps/wapi-ai-chatbot/src/utils/cache.ts

View workflow job for this annotation

GitHub Actions / build-and-lint

Unexpected any. Specify a different type
const { key, ttl, data } = params
await cacheStore.set(key, data, { ...(ttl ? { ttl: ttl } : {}) })
const { key, ttl, data } = params
await cacheStore.set(key, data, { ...(ttl ? { ttl: ttl } : {}) })
}

export async function getCachedData<T>(key: string): Promise<T> {
const response = await cacheStore.get(key)
console.log(response)
return response as T
const response = await cacheStore.get(key)
console.log(response)
return response as T
}

export function computeCacheKey(params: { id: string; context: string }) {
return `${params.id}-${params.context}`
return `${params.id}-${params.context}`
}

export function getConversationContextCacheKey(phoneNumber: string) {
return computeCacheKey({
id: phoneNumber,
context: 'conversation'
})
return computeCacheKey({
id: phoneNumber,
context: 'conversation'
})
}

0 comments on commit 087c668

Please sign in to comment.