@sourceloop/cache / Exports
@sourceloop/cache¶
Table of contents¶
Namespaces¶
Enumerations¶
Classes¶
Interfaces¶
- ICacheComponentOptions
- ICacheMixinOptions
- ICacheOptions
- ICacheService
- ICacheStore
- ICachedMethodOptions
- ICachedRepository
- ICachedService
Type Aliases¶
Variables¶
Functions¶
Type Aliases¶
AbstractConstructor¶
Ƭ AbstractConstructor<T>: (...args: any[]) => T
Type parameters¶
| Name |
|---|
T |
Type declaration¶
• (...args)
Parameters¶
| Name | Type |
|---|---|
...args |
any[] |
Defined in¶
CacheMethod¶
Ƭ CacheMethod<T>: (...args: any[]) => Promise<T>
Type parameters¶
| Name |
|---|
T |
Type declaration¶
▸ (...args): Promise<T>
Parameters¶
| Name | Type |
|---|---|
...args |
any[] |
Returns¶
Promise<T>
Defined in¶
Variables¶
AUTH_USER_KEY¶
• Const AUTH_USER_KEY: BindingKey<undefined | IAuthUserWithPermissions<string, string, string>>
Defined in¶
CachingComponentNamespace¶
• Const CachingComponentNamespace: "sourceloop.caching.extension"
Defined in¶
Functions¶
CacheMixin¶
▸ CacheMixin<M, ID, Relations, S>(superClass, cacheOptions?): typeof superClass & AbstractConstructor<ICachedRepository<M, ID, Relations>> & { prototype: ICachedRepository<M, ID, Relations> }
This is a mixin function that adds caching functionality to a given repository class.
Type parameters¶
| Name | Type |
|---|---|
M |
extends Entity<M> |
ID |
ID |
Relations |
extends object |
S |
extends AbstractConstructor<DefaultCrudRepository<M, ID, Relations>> |
Parameters¶
| Name | Type | Description |
|---|---|---|
superClass |
S & AbstractConstructor<DefaultCrudRepository<M, ID, Relations>> |
The superclass is a generic type parameter that extends the DefaultCrudRepository class. It represents the base repository class that the CacheMixin will extend and add caching functionality to. |
cacheOptions? |
ICacheMixinOptions |
cacheOptions is an optional parameter of type ICacheMixinOptions. It is used to configure the caching behavior of the repository. |
Returns¶
typeof superClass & AbstractConstructor<ICachedRepository<M, ID, Relations>> & { prototype: ICachedRepository<M, ID, Relations> }
Defined in¶
cacheInvalidator¶
▸ cacheInvalidator<T>(tags?): <S>(target: T, methodName: string, descriptor: TypedPropertyDescriptor<CacheMethod<S>>) => TypedPropertyDescriptor<CacheMethod<S>>
This is a TypeScript function that invalidates cache items based on specified tags.
Type parameters¶
| Name | Type |
|---|---|
T |
extends ICachedService |
Parameters¶
| Name | Type | Default value | Description |
|---|---|---|---|
tags |
string[] |
[] |
An optional array of strings that represent tags associated with the cached data. These tags can be used to selectively invalidate cached data. |
Returns¶
fn
The function cacheInvalidator is being returned.
▸ <S>(target, methodName, descriptor): TypedPropertyDescriptor<CacheMethod<S>>
Type parameters¶
| Name |
|---|
S |
Parameters¶
| Name | Type |
|---|---|
target |
T |
methodName |
string |
descriptor |
TypedPropertyDescriptor<CacheMethod<S>> |
Returns¶
TypedPropertyDescriptor<CacheMethod<S>>
Defined in¶
decorators/cache-invalidator.decorator.ts:9
cachedItem¶
▸ cachedItem<T>(tags?, ignoredParamIndexes?): <S>(target: T, methodName: string, descriptor?: TypedPropertyDescriptor<CacheMethod<S>>) => TypedPropertyDescriptor<CacheMethod<S>>
This is a TypeScript decorator function that caches the result of a method call and retrieves it from the cache if available, otherwise it calls the original method and saves the result in the cache.
Type parameters¶
| Name | Type |
|---|---|
T |
extends ICachedService |
Parameters¶
| Name | Type | Default value | Description |
|---|---|---|---|
tags |
string[] |
[] |
The tags parameter is an optional array of strings that can be passed to the cachedItem decorator function. These tags can be used to group cached items together and make it easier to invalidate or clear a specific group of cached items. |
ignoredParamIndexes |
number[] |
[] |
- |
Returns¶
fn
The cachedItem function returns a decorator function that can be used to decorate a class
method with caching functionality.
▸ <S>(target, methodName, descriptor?): TypedPropertyDescriptor<CacheMethod<S>>
Type parameters¶
| Name |
|---|
S |
Parameters¶
| Name | Type |
|---|---|
target |
T |
methodName |
string |
descriptor? |
TypedPropertyDescriptor<CacheMethod<S>> |
Returns¶
TypedPropertyDescriptor<CacheMethod<S>>