Skip to content

Commit

Permalink
Added forceBypassCache property to request model.
Browse files Browse the repository at this point in the history
  • Loading branch information
mspalti committed Oct 15, 2019
1 parent 4b03f76 commit ef4ae44
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/app/core/data/request.models.ts
Expand Up @@ -24,6 +24,7 @@ import { MappedCollectionsReponseParsingService } from './mapped-collections-rep

export abstract class RestRequest {
public responseMsToLive = 10 * 1000;
public forceBypassCache = false;
constructor(
public uuid: string,
public href: string,
Expand Down Expand Up @@ -293,6 +294,7 @@ export class UpdateMetadataFieldRequest extends PutRequest {
* Class representing a submission HTTP GET request object
*/
export class SubmissionRequest extends GetRequest {
forceBypassCache = true;
constructor(uuid: string, href: string) {
super(uuid, href);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/data/request.service.ts
Expand Up @@ -148,7 +148,7 @@ export class RequestService {
*/
configure<T extends CacheableObject>(request: RestRequest): void {
const isGetRequest = request.method === RestRequestMethod.GET;
if (!isGetRequest || !this.isCachedOrPending(request)) {
if (!isGetRequest || request.forceBypassCache || !this.isCachedOrPending(request)) {
this.dispatchRequest(request);
if (isGetRequest) {
this.trackRequestsOnTheirWayToTheStore(request);
Expand Down
3 changes: 2 additions & 1 deletion src/app/core/submission/submission-rest.service.spec.ts
Expand Up @@ -60,7 +60,8 @@ describe('SubmissionRestService test suite', () => {
it('should configure a new SubmissionRequest', () => {
const expected = new SubmissionRequest(requestService.generateRequestId(), resourceHref);
// set cache time to zero
expected.responseMsToLive = 10 * 1000;
expected.responseMsToLive = 0;
expected.forceBypassCache = true;
scheduler.schedule(() => service.getDataById(resourceEndpoint, resourceScope).subscribe());
scheduler.flush();

Expand Down

0 comments on commit ef4ae44

Please sign in to comment.