mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge remote-tracking branch 'atmire-internal/responseMsToLive' into patch-support
Conflicts: src/app/core/data/request.models.ts src/config/cache-config.interface.ts
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
|
||||
autoSync: {
|
||||
|
@@ -125,7 +125,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))
|
||||
);
|
||||
|
||||
|
@@ -21,7 +21,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
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -35,9 +36,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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,10 @@ import { Config } from './config.interface';
|
||||
import { AutoSyncConfig } from './auto-sync-config.interface';
|
||||
|
||||
export interface CacheConfig extends Config {
|
||||
msToLive: number,
|
||||
msToLive: {
|
||||
default: number;
|
||||
exportToZip: number;
|
||||
},
|
||||
control: string,
|
||||
autoSync: AutoSyncConfig
|
||||
}
|
||||
|
Reference in New Issue
Block a user