Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#14704 closed defect (fixed)

Cache store wrapper returns result from caching store instead of master store

Reported by: Kris Zyp Owned by: Kris Zyp
Priority: undecided Milestone: 1.8
Component: Data Version: 1.7.1
Keywords: Cc:
Blocked By: Blocking:

Description

The results returned from an add() or put() call on the Cache wrapper should return the results delegated add() or put() from the master store, but instead it is returning the results of the delegate add() or put() to the caching store.

Change History (6)

comment:1 Changed 8 years ago by Kris Zyp

Owner: set to Kris Zyp
Resolution: fixed
Status: newclosed

In [27713]:

Return results from the master store for add() and put() calls, fixes #14704 !strict

comment:2 Changed 8 years ago by Kris Zyp

If you need this fixed in 1.7, you could create a patched Cache store wrapper:

FixedCache = function(masterStore, cachingStore, options){
	var store = Cache(masterStore, cachingStore, options);
	store.add = function(object, directives){
			return Deferred.when(masterStore.add(object, directives), function(result){
				// now put result in cache
				cachingStore.add(typeof result == "object" ? result : object, directives);
				return result; // the result from the add should be dictated by the masterStore and be unaffected by the cachingStore
			});
		};
	store.put = function(object, directives){
			// first remove from the cache, so it is empty until we get a response from the master store
			cachingStore.remove((directives && directives.id) || this.getIdentity(object));
			return Deferred.when(masterStore.put(object, directives), function(result){
				// now put result in cache
				cachingStore.put(typeof result == "object" ? result : object, directives);
				return result; // the result from the put should be dictated by the masterStore and be unaffected by the cachingStore
			});
		};
};
Version 0, edited 8 years ago by Kris Zyp (next)

comment:3 in reply to:  1 Changed 8 years ago by ben hockey

Replying to kzyp:

In [27713]:

Return results from the master store for add() and put() calls, fixes #14704 !strict

in the test, did you mean to stash the original value for masterStore.add rather than masterStore.put?

comment:4 Changed 8 years ago by Kris Zyp

In [27714]:

Stash add instead of put, refs #14704 !strict

comment:5 Changed 8 years ago by bill

Component: GeneralData

comment:6 Changed 8 years ago by bill

Milestone: tbd1.8

No milestone specified, bulk update to 1.8.

Note: See TracTickets for help on using tickets.