mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
RequestCache: started tracking timeAdded and timeToLive
This commit is contained in:
8
src/app/core/cache/request-cache.actions.ts
vendored
8
src/app/core/cache/request-cache.actions.ts
vendored
@@ -63,13 +63,15 @@ export class RequestCacheSuccessAction implements Action {
|
||||
type = RequestCacheActionTypes.SUCCESS;
|
||||
payload: {
|
||||
key: string,
|
||||
resourceUUIDs: Array<string>
|
||||
resourceUUIDs: Array<string>,
|
||||
msToLive: number
|
||||
};
|
||||
|
||||
constructor(key: string, resourceUUIDs: Array<string>) {
|
||||
constructor(key: string, resourceUUIDs: Array<string>, msToLive: number) {
|
||||
this.payload = {
|
||||
key,
|
||||
resourceUUIDs
|
||||
resourceUUIDs,
|
||||
msToLive
|
||||
};
|
||||
}
|
||||
}
|
||||
|
4
src/app/core/cache/request-cache.reducer.ts
vendored
4
src/app/core/cache/request-cache.reducer.ts
vendored
@@ -83,7 +83,9 @@ function success(state: RequestCacheState, action: RequestCacheSuccessAction): R
|
||||
[action.payload.key]: Object.assign({}, state[action.payload.key], {
|
||||
isLoading: false,
|
||||
resourceUUIDs: action.payload.resourceUUIDs,
|
||||
errorMessage: undefined
|
||||
errorMessage: undefined,
|
||||
timeAdded: new Date().getTime(),
|
||||
msToLive: action.payload.msToLive
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ export abstract class DataEffects<T extends CacheableObject> {
|
||||
});
|
||||
})
|
||||
.map((ts: Array<T>) => ts.map(t => t.uuid))
|
||||
.map((ids: Array<string>) => new RequestCacheSuccessAction(action.payload.key, ids))
|
||||
.map((ids: Array<string>) => new RequestCacheSuccessAction(action.payload.key, ids, GlobalConfig.cache.msToLive))
|
||||
.catch((errorMsg: string) => Observable.of(new RequestCacheErrorAction(action.payload.key, errorMsg)));
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ export abstract class DataEffects<T extends CacheableObject> {
|
||||
.do((t: T) => {
|
||||
this.objectCache.add(t, GlobalConfig.cache.msToLive);
|
||||
})
|
||||
.map((t: T) => new RequestCacheSuccessAction(action.payload.key, [t.uuid]))
|
||||
.map((t: T) => new RequestCacheSuccessAction(action.payload.key, [t.uuid], GlobalConfig.cache.msToLive))
|
||||
.catch((errorMsg: string) => Observable.of(new RequestCacheErrorAction(action.payload.key, errorMsg)));
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user