From 4a6d886327b4f36136c83747fb964cd1062b1f36 Mon Sep 17 00:00:00 2001 From: jlenon7 Date: Wed, 13 Aug 2025 16:39:34 -0300 Subject: [PATCH] chore(cache): add type for custom connections --- package-lock.json | 4 ++-- package.json | 2 +- src/cache/CacheImpl.ts | 13 +++++-------- src/index.ts | 1 + 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index de20547..4eff2b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/cache", - "version": "5.0.0", + "version": "5.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@athenna/cache", - "version": "5.0.0", + "version": "5.1.0", "license": "MIT", "dependencies": { "lru-cache": "^11.1.0" diff --git a/package.json b/package.json index 75a0adc..0ea3580 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/cache", - "version": "5.0.0", + "version": "5.1.0", "description": "The cache handler for Athenna Framework.", "license": "MIT", "author": "João Lenon ", diff --git a/src/cache/CacheImpl.ts b/src/cache/CacheImpl.ts index db8304d..c6394c3 100644 --- a/src/cache/CacheImpl.ts +++ b/src/cache/CacheImpl.ts @@ -22,7 +22,7 @@ export class CacheImpl extends Macroable { /** * The drivers responsible for handling cache operations. */ - public driver: MemoryDriver = null + public driver: Driver = null /** * Creates a new instance of CacheImpl. @@ -33,13 +33,13 @@ export class CacheImpl extends Macroable { this.driver = StoreFactory.fabricate( this.storeName, athennaCacheOpts?.options - ) + ) as unknown as Driver this.connect(athennaCacheOpts) } - public store(con: 'memory', options?: StoreOptions): CacheImpl - + public store(store: 'memory', options?: StoreOptions): CacheImpl + public store(store: 'memory' | string): CacheImpl /** * Change the store connection. * @@ -48,10 +48,7 @@ export class CacheImpl extends Macroable { * await Cache.store('redis').set('my:cache:key', 'hello') * ``` */ - public store( - store: 'memory' | string, - options?: StoreOptions - ): CacheImpl { + public store(store: 'memory' | string, options?: StoreOptions) { const driver = StoreFactory.fabricate(store, options?.options) const cache = new CacheImpl(options) diff --git a/src/index.ts b/src/index.ts index b676a8a..fe28bc1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,5 +10,6 @@ export * from '#src/types' export * from '#src/facades/Cache' export * from '#src/cache/CacheImpl' +export * from '#src/factories/StoreFactory' export * from '#src/providers/CacheProvider' export * from '#src/cache/drivers/MemoryDriver'