Skip to content

Commit 4a6d886

Browse files
committed
chore(cache): add type for custom connections
1 parent 24d26c9 commit 4a6d886

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@athenna/cache",
3-
"version": "5.0.0",
3+
"version": "5.1.0",
44
"description": "The cache handler for Athenna Framework.",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",

src/cache/CacheImpl.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class CacheImpl<Driver extends DriverImpl = any> extends Macroable {
2222
/**
2323
* The drivers responsible for handling cache operations.
2424
*/
25-
public driver: MemoryDriver = null
25+
public driver: Driver = null
2626

2727
/**
2828
* Creates a new instance of CacheImpl.
@@ -33,13 +33,13 @@ export class CacheImpl<Driver extends DriverImpl = any> extends Macroable {
3333
this.driver = StoreFactory.fabricate(
3434
this.storeName,
3535
athennaCacheOpts?.options
36-
)
36+
) as unknown as Driver
3737

3838
this.connect(athennaCacheOpts)
3939
}
4040

41-
public store(con: 'memory', options?: StoreOptions): CacheImpl<MemoryDriver>
42-
41+
public store(store: 'memory', options?: StoreOptions): CacheImpl<MemoryDriver>
42+
public store(store: 'memory' | string): CacheImpl<MemoryDriver>
4343
/**
4444
* Change the store connection.
4545
*
@@ -48,10 +48,7 @@ export class CacheImpl<Driver extends DriverImpl = any> extends Macroable {
4848
* await Cache.store('redis').set('my:cache:key', 'hello')
4949
* ```
5050
*/
51-
public store(
52-
store: 'memory' | string,
53-
options?: StoreOptions
54-
): CacheImpl<Driver> {
51+
public store(store: 'memory' | string, options?: StoreOptions) {
5552
const driver = StoreFactory.fabricate(store, options?.options)
5653
const cache = new CacheImpl<typeof driver>(options)
5754

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
export * from '#src/types'
1111
export * from '#src/facades/Cache'
1212
export * from '#src/cache/CacheImpl'
13+
export * from '#src/factories/StoreFactory'
1314
export * from '#src/providers/CacheProvider'
1415
export * from '#src/cache/drivers/MemoryDriver'

0 commit comments

Comments
 (0)