1 import { MedusaModule } from "@medusajs/framework/modules-sdk"
2 import {
3 ExternalModuleDeclaration,
4 ICacheService,
5 InternalModuleDeclaration,
6 } from "@medusajs/framework/types"
7 import { Modules } from "@medusajs/framework/utils"
8 import { RedisCacheModuleOptions } from "../types"
9
10 export const initialize = async (
11 options?: RedisCacheModuleOptions | ExternalModuleDeclaration
12 ): Promise<ICacheService> => {
13 const serviceKey = Modules.CACHE
14 const loaded = await MedusaModule.bootstrap<ICacheService>({
15 moduleKey: serviceKey,
16 defaultPath: "@medusajs/cache-redis",
17 declaration: options as
18 | InternalModuleDeclaration
19 | ExternalModuleDeclaration,
20 })
21
22 return loaded[serviceKey]
23 }