954b1a9f11
* WIP prices + new caching utils * cached workspace plan prices * GQL API done * integrated in frontend * fixed missing FF * CR fixes * integration tests * removed non-existant team yearly env var
24 lines
661 B
TypeScript
24 lines
661 B
TypeScript
import { redisCacheProviderFactory } from '@/modules/shared/utils/caching'
|
|
import { Optional } from '@speckle/shared'
|
|
import Redis from 'ioredis'
|
|
import MockRedis from 'ioredis-mock'
|
|
|
|
let client: Optional<Redis> = undefined
|
|
|
|
const createMockRedis = () => new MockRedis() as unknown as Redis
|
|
|
|
export function getInmemoryRedisClient(): Redis {
|
|
if (!client) {
|
|
client = createMockRedis()
|
|
}
|
|
|
|
return client
|
|
}
|
|
|
|
export const mockRedisCacheProviderFactory = (
|
|
options?: Partial<{ createNewCache: boolean }>
|
|
) => {
|
|
const client = options?.createNewCache ? createMockRedis() : getInmemoryRedisClient()
|
|
return redisCacheProviderFactory({ redis: client })
|
|
}
|