typeorm-cache
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -5,5 +5,9 @@ import Keyv from 'keyv'; | ||
import { QueryResultCacheOptions } from 'typeorm/cache/QueryResultCacheOptions'; | ||
export interface KeyvCacheProviderOptions extends Keyv.Options<any> { | ||
keyPrefix?: string; | ||
} | ||
export declare class KeyvCacheProvider implements QueryResultCache { | ||
cache: Keyv; | ||
constructor(opts?: Keyv.Options<any>); | ||
keyPrefix: string; | ||
constructor(opts?: KeyvCacheProviderOptions); | ||
private generateIdentifier; | ||
@@ -10,0 +14,0 @@ connect(): Promise<void>; |
@@ -20,6 +20,8 @@ "use strict"; | ||
constructor(opts) { | ||
const { keyPrefix } = opts || {}; | ||
this.cache = new keyv_1.default(opts); | ||
this.keyPrefix = keyPrefix || 'typeorm:cache:'; | ||
} | ||
generateIdentifier(query) { | ||
return query && crypto_1.createHash('md5').update(query).digest('hex'); | ||
return query && `${this.keyPrefix}${crypto_1.createHash('md5').update(query).digest('hex')}`; | ||
} | ||
@@ -26,0 +28,0 @@ connect() { |
{ | ||
"name": "typeorm-cache", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A typeorm cache provider based on keyv.", | ||
@@ -5,0 +5,0 @@ "main": "./lib", |
Sorry, the diff of this file is not supported yet
10787
112