Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

awesome changes to the resource store cache #516

Closed
wants to merge 1 commit into from

1 participant

@diervo

Aded caching by instace before expansion.

@diervo diervo awesome changes to the resource store cache
Aded caching by instace before expansion.
fb4565b
@diervo diervo closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 14, 2012
  1. @diervo

    awesome changes to the resource store cache

    diervo authored
    Aded caching by instace before expansion.
This page is out of date. Refresh to see the latest.
Showing with 24 additions and 5 deletions.
  1. +24 −5 lib/store.server.js
View
29 lib/store.server.js
@@ -223,6 +223,10 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
* @return {nothing} if this method returns at all then the context is valid
*/
validateContext: function(ctx) {
+
+ // << RIC
+ return true;
+
var k,
parts,
p,
@@ -536,14 +540,21 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
* @param {function(err,instance)} cb callback used to return the results (or error)
*/
expandInstanceForEnv: function(env, instance, ctx, cb) {
- var cacheKey = Y.JSON.stringify(instance) + Y.JSON.stringify(ctx),
+ var fakeInstance = {
+ base: instance.base,
+ action: instance.action,
+ type: instance.type,
+ id: instance.id
+ },
+ cacheKey = JSON.stringify([fakeInstance, ctx]),
cacheValue = this._expandInstanceCache[env][cacheKey],
spec,
typeDetails,
- config;
+ config,
+ perf;
if (cacheValue) {
- cb(null, Y.mojito.util.copy(cacheValue));
+ cb(null, Y.merge(Y.mojito.util.copy(cacheValue), instance));
return;
}
@@ -565,9 +576,14 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
delete spec.appConfig.specs;
try {
+ perf = Y.mojito.perf.timeline('mojito', 'store:getMojitTypeDetails',
+ 'expand mojit spec', spec.type);
+
this.getMojitTypeDetails(env, ctx, spec.type, spec);
} catch (err2) {
return cb(err2);
+ } finally {
+ perf.done();
}
if (spec.defaults && spec.defaults.config) {
config = Y.mojito.util.copy(spec.defaults.config);
@@ -575,8 +591,11 @@ YUI.add('mojito-resource-store', function(Y, NAME) {
spec.config = config;
}
- this._expandInstanceCache[env][cacheKey] = Y.mojito.util.copy(spec);
- cb(null, spec);
+ this._expandInstanceCache[env][cacheKey] = spec;
+
+ //WTF we are doing the copy here?????
+ cb(null, Y.merge(Y.mojito.util.copy(spec), instance));
+ //cb(null, spec);
},
Something went wrong with that request. Please try again.