You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside getOrCreateResource, the following is called:
public getOrCreateResource(id: string): R {
let service = Converter.getServiceOrFail(this.type);
let resource: R;
resource = <R>CacheMemory.getInstance().getResource(this.type, id);
if (resource === null) {
resource = <R>service.new();
resource.id = id;
CacheMemory.getInstance().setResource(resource, false);
}
if (resource.source !== 'new') {
resource.source = 'memory';
}
return resource;
}
The Problem
On the first invocation of Service.all(paramsCollection), it doesn't find anything, but it then always caches every returned resource.
On each subsequent invocation of .all the CacheMemory will have the resource and return the cached resource.
I have fixed this by extending the Resource service and overriding getOrCreateResource and createResource to remove the CacheMemory logic.
Suggested Solution
The CacheMemory code in Service.tsgetOrCreateResource and Service.tscreateResource needs a similar cachestore_support check, like this commit has: 5b964f9
Issue
I've disabled caching:
When I make a query like so:
The
Service.getAllFromServer
handles the response with this stack:Inside getOrCreateResource, the following is called:
The Problem
On the first invocation of
Service.all(paramsCollection)
, it doesn't find anything, but it then always caches every returned resource.On each subsequent invocation of
.all
the CacheMemory will have the resource and return the cached resource.I have fixed this by extending the
Resource
service and overridinggetOrCreateResource
andcreateResource
to remove the CacheMemory logic.Suggested Solution
The CacheMemory code in
Service.ts
getOrCreateResource
andService.ts
createResource
needs a similarcachestore_support
check, like this commit has: 5b964f9https://github.com/reyesoft/ngx-jsonapi/blob/v2.1/src/service.ts#L369
The text was updated successfully, but these errors were encountered: