mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
add responseMsToLive to requests
This commit is contained in:
@@ -18,7 +18,10 @@ module.exports = {
|
||||
// Caching settings
|
||||
cache: {
|
||||
// NOTE: how long should objects be cached for by default
|
||||
msToLive: 15 * 60 * 1000, // 15 minutes
|
||||
msToLive: {
|
||||
default: 15 * 60 * 1000, // 15 minutes
|
||||
exportToZip: 5 * 1000 // 5 seconds
|
||||
},
|
||||
// msToLive: 1000, // 15 minutes
|
||||
control: 'max-age=60' // revalidate browser
|
||||
},
|
||||
|
@@ -126,7 +126,7 @@ export abstract class BaseResponseParsingService {
|
||||
if (hasNoValue(co) || hasNoValue(co.self)) {
|
||||
throw new Error('The server returned an invalid object');
|
||||
}
|
||||
this.objectCache.add(co, this.EnvConfig.cache.msToLive, requestHref);
|
||||
this.objectCache.add(co, this.EnvConfig.cache.msToLive.default, requestHref);
|
||||
}
|
||||
|
||||
processPageInfo(payload: any): PageInfo {
|
||||
|
@@ -23,7 +23,7 @@ import { catchError, flatMap, map, take, tap } from 'rxjs/operators';
|
||||
export const addToResponseCacheAndCompleteAction = (request: RestRequest, responseCache: ResponseCacheService, envConfig: GlobalConfig) =>
|
||||
(source: Observable<ErrorResponse>): Observable<RequestCompleteAction> =>
|
||||
source.pipe(
|
||||
tap((response: RestResponse) => responseCache.add(request.href, response, envConfig.cache.msToLive)),
|
||||
tap((response: RestResponse) => responseCache.add(request.href, response, request.responseMsToLive ? request.responseMsToLive : envConfig.cache.msToLive.default)),
|
||||
map((response: RestResponse) => new RequestCompleteAction(request.uuid))
|
||||
);
|
||||
|
||||
|
@@ -41,7 +41,8 @@ export abstract class RestRequest {
|
||||
public href: string,
|
||||
public method: RestRequestMethod = RestRequestMethod.Get,
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
public options?: HttpOptions,
|
||||
public responseMsToLive?: number
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -55,9 +56,10 @@ export class GetRequest extends RestRequest {
|
||||
public uuid: string,
|
||||
public href: string,
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
public options?: HttpOptions,
|
||||
public responseMsToLive?: number
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Get, body)
|
||||
super(uuid, href, RestRequestMethod.Get, body, options, responseMsToLive)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,9 @@
|
||||
import { Config } from './config.interface';
|
||||
|
||||
export interface CacheConfig extends Config {
|
||||
msToLive: number,
|
||||
msToLive: {
|
||||
default: number;
|
||||
exportToZip: number;
|
||||
},
|
||||
control: string
|
||||
}
|
||||
|
Reference in New Issue
Block a user