UNPKG

@ngx-toolkit/cache

Version:

Angular cache with Universal support

1 lines 20.2 kB
{"version":3,"file":"ngx-toolkit-cache.mjs","sources":["../../../projects/cache/src/lib/cache.instance.ts","../../../projects/cache/src/lib/simple-cache.manager.ts","../../../projects/cache/src/lib/cache.module.ts","../../../projects/cache/src/lib/cache.decorator.ts","../../../projects/cache/src/lib/impl/no-op-cache.ts","../../../projects/cache/src/lib/impl/storage-cache.ts","../../../projects/cache/src/lib/impl/memory-cache.ts","../../../projects/cache/src/public-api.ts","../../../projects/cache/src/ngx-toolkit-cache.ts"],"sourcesContent":["import {CacheManager} from './cache.manager';\n\nconst CACHE_INSTANCE = {\n manager: undefined\n};\n\n\nexport function initCacheManager(cacheManager: CacheManager) {\n CACHE_INSTANCE.manager = cacheManager;\n}\n\nexport function getCacheManager(): CacheManager {\n if (!CACHE_INSTANCE.manager) {\n throw new Error('No cache found, `initCacheManager` before');\n }\n return CACHE_INSTANCE.manager;\n}\n","import {CacheManager} from './cache.manager';\nimport {Cache} from './cache.model';\n\nexport class SimpleCacheManager implements CacheManager {\n private cacheMap: Map<string, Cache>;\n\n constructor(caches?: Cache[]) {\n this.setCaches(caches);\n }\n\n getCacheNames(): string[] {\n return Array.from(this.cacheMap.keys());\n }\n\n getCache(name: string): Cache {\n return this.cacheMap.get(name) || null;\n }\n\n addCache(cache: Cache): void {\n if (!cache) {\n throw new Error('Cache is undefined');\n }\n this.cacheMap.set(cache.name, cache);\n }\n\n setCaches(caches: Cache[]): void {\n this.cacheMap = new Map<string, Cache>();\n if (caches) {\n caches.forEach(cache => this.addCache(cache));\n }\n }\n}\n","import {CommonModule} from '@angular/common';\nimport {ModuleWithProviders, NgModule} from '@angular/core';\nimport {initCacheManager} from './cache.instance';\nimport {Cache} from './cache.model';\nimport {SimpleCacheManager} from './simple-cache.manager';\n\n@NgModule({\n imports: [CommonModule]\n})\nexport class CacheModule {\n /**\n * In root module to provide caches\n */\n static forRoot(caches: Cache[]): ModuleWithProviders<CacheModule> {\n initCacheManager(new SimpleCacheManager(caches));\n\n return {\n ngModule: CacheModule\n };\n }\n}\n","import 'reflect-metadata/Reflect';\nimport {getCacheManager} from './cache.instance';\nimport {Cache} from './cache.model';\n\nexport const METADATA_KEY_CACHE_DEFAULTS = '_cache_defaults';\nexport const METADATA_KEY_CACHE_KEYS = '_cache_keys';\nexport const METADATA_KEY_CACHE_VALUE = '_cache_value';\n\nexport interface CacheParams {\n cacheName?: string;\n}\n\nexport interface CacheParamsInvoc extends CacheParams {\n afterInvocation?: boolean;\n}\n\n/**\n * Allows the configuration of defaults for `CacheResult`, `CachePut`, `CacheRemove`, and `CacheRemoveAll` at the class level.\n * Without the method level annotations this annotation has no effect.\n *\n * @param cacheName\n */\nexport function CacheDefaults(cacheName: string): ClassDecorator {\n return (target: Function): void => {\n Reflect.defineMetadata(METADATA_KEY_CACHE_DEFAULTS, cacheName, target);\n };\n}\n\n/**\n * When a method annotated with `CacheResult` is invoked a cache key will be generated\n * and *Cache.get(key)* is called before the annotated method actually executes.\n * If a value is found in the cache it is returned and the annotated method is never actually executed.\n * If no value is found the annotated method is invoked and the returned value is stored in the cache with the generated key.\n *\n * @param params (Optional) {cacheName?: string}\n */\nexport function CacheResult(params?: CacheParams): MethodDecorator {\n params = getDefaultParams<CacheParams>(params);\n\n return (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> => {\n const originalMethod = descriptor.value;\n descriptor.value = function(...args: any[]) {\n const cache: Cache = getCache(target, params);\n const cacheKey: string = getCacheKey(target, propertyKey, args);\n\n // Find cache value\n let result: any = cache.get(cacheKey);\n\n // Call function & save function if no cache value\n if (result === undefined) {\n // Call function & save result\n result = originalMethod.apply(this, args);\n cache.put(cacheKey, result);\n }\n\n return result;\n };\n return descriptor;\n };\n}\n\n/**\n * Marks a method argument as part of the cache key.\n * If no arguments are marked all arguments are used.\n * The exception is for a method annotated with `CachePut` where the `CacheValue` parameter is never included in the key.\n */\nexport function CacheKey(): ParameterDecorator {\n return (target: Object, propertyKey: string | symbol, parameterIndex: number) => {\n const indices = Reflect.getMetadata(`${METADATA_KEY_CACHE_KEYS}_${propertyKey.toString()}`, target, propertyKey) || [];\n indices.push(parameterIndex);\n Reflect.defineMetadata(`${METADATA_KEY_CACHE_KEYS}_${propertyKey.toString()}`, indices, target, propertyKey);\n };\n}\n\n/**\n * When a method annotated with `CachePut` is invoked a cache key will be generated\n * and *Cache.put(key, value)* will be invoked on the specified cache storing the value marked with `CacheValue`.\n *\n * @param params (Optional) {cacheName?: string, afterInvocation: boolean = true}\n */\nexport function CachePut(params?: CacheParamsInvoc): MethodDecorator {\n params = getDefaultParams<CacheParamsInvoc>(params);\n\n return (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> => {\n const originalMethod = descriptor.value;\n descriptor.value = function(...args: any[]) {\n const cache: Cache = getCache(target, params);\n const indexValue: number = Reflect.getMetadata(`${METADATA_KEY_CACHE_VALUE}_${propertyKey.toString()}`, target, propertyKey);\n const cacheKey: string = getCacheKey(target, propertyKey, args, indexValue);\n\n if (!params.afterInvocation && indexValue && indexValue >= 0 && indexValue < args.length) {\n cache.put(cacheKey, args[indexValue]);\n }\n\n const result = originalMethod.apply(this, args);\n\n if (params.afterInvocation && indexValue && indexValue >= 0 && indexValue < args.length) {\n cache.put(cacheKey, args[indexValue]);\n }\n\n return result;\n };\n return descriptor;\n };\n}\n\n/**\n * Marks the parameter to be cached for a method annotated with `CachePut`.\n */\nexport function CacheValue(): ParameterDecorator {\n return (target: Object, propertyKey: string | symbol, parameterIndex: number) => {\n Reflect.defineMetadata(`${METADATA_KEY_CACHE_VALUE}_${propertyKey.toString()}`, parameterIndex, target, propertyKey);\n };\n}\n\n/**\n * When a method annotated with `CacheRemove` is invoked a cache key will be generated\n * and *Cache.remove(key)* will be invoked on the specified cache.\n * The default behavior is to call *Cache.evict(key)* after the annotated method is invoked,\n * this behavior can be changed by setting *`afterInvocation`* to false in which case *Cache.evict(key)*\n * will be called before the annotated method is invoked.\n *\n * @param params (Optional) {cacheName?: string, afterInvocation: boolean = true}\n */\nexport function CacheRemove(params?: CacheParamsInvoc): MethodDecorator {\n params = getDefaultParams<CacheParamsInvoc>(params);\n\n return (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> => {\n const originalMethod = descriptor.value;\n descriptor.value = function(...args: any[]) {\n const cache: Cache = getCache(target, params);\n const cacheKey: string = getCacheKey(target, propertyKey, args);\n\n if (!params.afterInvocation) {\n cache.evict(cacheKey);\n }\n\n const result: any = originalMethod.apply(this, args);\n\n\n if (params.afterInvocation) {\n cache.evict(cacheKey);\n }\n\n return result;\n };\n return descriptor;\n };\n}\n\n/**\n * When a method annotated with `CacheRemoveAll` is invoked all elements in the specified cache will be removed via the *Cache.clear()* method.\n * The default behavior is to call *Cache.clear()* after the annotated method is invoked,\n * this behavior can be changed by setting *`afterInvocation`* to false in which case *Cache.clear()* will be called before the annotated method is invoked.\n *\n * @param params (Optional) {cacheName?: string, afterInvocation: boolean = true}\n */\nexport function CacheRemoveAll(params?: CacheParamsInvoc): MethodDecorator {\n params = getDefaultParams<CacheParamsInvoc>(params);\n\n return (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> => {\n const originalMethod = descriptor.value;\n descriptor.value = function(...args: any[]) {\n const cache: Cache = getCache(target, params);\n if (!params.afterInvocation) {\n cache.clear();\n }\n\n const result: any = originalMethod.apply(this, args);\n\n if (params.afterInvocation) {\n cache.clear();\n }\n\n return result;\n };\n return descriptor;\n };\n}\n\nfunction getDefaultParams<T>(cacheParams: CacheParams): { afterInvocation: boolean } & CacheParams {\n return Object.assign({\n afterInvocation: true\n }, cacheParams || {});\n}\n\nfunction getCache(target: Object, params: CacheParams): Cache {\n if (!params.cacheName) {\n params.cacheName = Reflect.getMetadata(METADATA_KEY_CACHE_DEFAULTS, target.constructor) || '';\n }\n\n const cache: Cache = getCacheManager().getCache(params.cacheName);\n if (!cache) {\n throw new Error(`Cache '${params.cacheName}' not found for ${target.constructor.name}`);\n }\n return cache;\n}\n\nfunction getCacheKey(target: Object, propertyKey: string | symbol, args: any[], cacheValueIndex = -1): string {\n if (!args) {\n args = [];\n }\n\n const indices: number[] = Reflect.getMetadata(`${METADATA_KEY_CACHE_KEYS}_${propertyKey.toString()}`, target, propertyKey);\n if (indices) {\n args = args.filter((value: any, index: number) => indices.indexOf(index) !== -1 && cacheValueIndex !== index);\n } else if (cacheValueIndex !== -1) {\n args = args.filter((value: any, index: number) => cacheValueIndex !== index);\n }\n\n if (args.length === 0) {\n throw new Error(`Couldn't generate key without params for '${propertyKey.toString()}' method of ${target.constructor.name}`);\n }\n\n return args.map(a => (JSON.stringify(a) || a.toString())).join('|');\n}\n","import {Cache} from '../cache.model';\n\nexport class NoOpCache implements Cache {\n\n readonly name: string;\n\n constructor(name: string) {\n this.name = name;\n }\n\n clear(): void {\n }\n\n evict(key: string): void {\n }\n\n get<T>(key: string): T {\n return undefined;\n }\n\n put<T>(key: string, value: T): void {\n }\n}\n","import {Cache} from '../cache.model';\n\nexport class StorageCache implements Cache {\n\n readonly name: string;\n private storage: Storage;\n\n constructor(name: string, storage: Storage) {\n this.name = name;\n this.storage = storage;\n }\n\n clear(): void {\n this.storage.clear();\n }\n\n evict(key: string): void {\n this.storage.removeItem(key);\n }\n\n get<T>(key: string): T {\n const value: string = this.storage.getItem(key);\n if (!value) {\n return undefined;\n }\n\n return <T> JSON.parse(value) || null;\n }\n\n put<T>(key: string, value: T): void {\n this.storage.setItem(key, JSON.stringify(value));\n }\n\n}\n","import {Cache} from '../cache.model';\n\nexport class MemoryCache implements Cache {\n\n readonly name: string;\n private cache: Map<string, any> = new Map<string, any>();\n\n constructor(name: string) {\n this.name = name;\n }\n\n clear(): void {\n this.cache.clear();\n }\n\n evict(key: string): void {\n this.cache.delete(key);\n }\n\n get<T>(key: string): T {\n return this.cache.get(key);\n }\n\n put<T>(key: string, value: T): void {\n this.cache.set(key, value);\n }\n\n}\n","/*\n * Public API Surface of cache\n */\n\nexport {CacheModule} from './lib/cache.module';\nexport {\n CacheDefaults, CacheResult, CacheKey, CacheValue, CachePut, CacheRemove, CacheRemoveAll\n}from './lib/cache.decorator';\nexport {CacheManager} from './lib/cache.manager';\nexport {SimpleCacheManager} from './lib/simple-cache.manager';\nexport {getCacheManager, initCacheManager} from './lib/cache.instance';\nexport {Cache} from './lib/cache.model';\nexport {NoOpCache} from './lib/impl/no-op-cache';\nexport {StorageCache} from './lib/impl/storage-cache';\nexport {MemoryCache} from './lib/impl/memory-cache';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAEA,MAAM,cAAc,GAAG;IACrB,OAAO,EAAE,SAAS;CACnB,CAAC;SAGc,gBAAgB,CAAC,YAA0B;IACzD,cAAc,CAAC,OAAO,GAAG,YAAY,CAAC;AACxC,CAAC;SAEe,eAAe;IAC7B,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IACD,OAAO,cAAc,CAAC,OAAO,CAAC;AAChC;;MCba,kBAAkB;IAG7B,YAAY,MAAgB;QAC1B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;KACxB;IAED,aAAa;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;KACzC;IAED,QAAQ,CAAC,IAAY;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;KACxC;IAED,QAAQ,CAAC,KAAY;QACnB,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;SACvC;QACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,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