Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mojito-cache

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mojito-cache - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

68

package.json
{
"name": "mojito-cache",
"version": "0.1.0",
"description": "A set of libraries for various caching strategies in mojito.",
"main": " ",
"scripts": {
"pretest": "mojito jslint app",
"test": "istanbul cover --yui=true --dir=artifacts/test/coverage ./node_modules/.bin/mojito -- test app .",
"posttest": "istanbul check-coverage --statements 80 --lines 80 --functions 80"
},
"repository": {
"type": "git",
"url": "git@github.com:yahoo/mojito-cache.git"
},
"keywords": [
"cache",
"caching",
"mojito"
],
"author": "arnoux@yahoo-inc.com",
"license": "BSD",
"engines": {
"node": "> 0.10",
"npm": "> 1.2",
"mojito": ">= 0.7.4"
},
"yahoo": {
"mojito": {
"type": "bundle"
"name": "mojito-cache",
"version": "0.1.1",
"description": "A set of libraries for various caching strategies in mojito.",
"main": " ",
"scripts": {
"pretest": "mojito jslint app",
"test": "istanbul cover --yui=true --dir=artifacts/test/coverage ./node_modules/.bin/mojito -- test app .",
"posttest": "istanbul check-coverage --statements 80 --lines 80 --functions 80"
},
"repository": {
"type": "git",
"url": "git@github.com:yahoo/mojito-cache.git"
},
"keywords": [
"cache",
"caching",
"mojito"
],
"author": "arnoux@yahoo-inc.com",
"license": "BSD",
"engines": {
"node": "> 0.10",
"npm": "> 1.2",
"mojito": ">= 0.7.4"
},
"yahoo": {
"mojito": {
"type": "bundle"
}
},
"devDependencies": {
"mojito": "0.9.0-rc.2",
"mojito-cli": "0.2.x",
"istanbul": "*"
}
},
"devDependencies": {
"mojito": "0.7.x",
"mojito-cli": "~0.0.5",
"istanbul": "*"
}
}

@@ -10,2 +10,3 @@ /*jslint nomen: true, indent: 4, plusplus: true, stupid: true */

suite = new YUITest.TestSuite(NAME),
BazAddon = function () {

@@ -15,2 +16,3 @@ this.cached = false;

},
QuuxAddon = function () {

@@ -32,5 +34,7 @@ this.cached = false;

};
this.baseCacheUsed = false;
this.typeCacheUsed = false;
this.__callIsUsed = false;
this.cachedAc = {

@@ -45,2 +49,3 @@ command: {

};
// mark those two cached to notice when they're reallocated

@@ -100,3 +105,6 @@ this.cachedAc.baz.cached = true;

adapter: {
req: req
req: req,
page: {
staticAppConfig: this.CONFIG
}
}

@@ -110,2 +118,3 @@ };

ac = new Y.mojito.ActionContext(acArgs);
// having both base and type results in being cached by base

@@ -116,3 +125,5 @@ A.isNotUndefined(req.globals['request-cache'].byBase.foo);

delete acArgs.command.instance.base;
ac = new Y.mojito.ActionContext(acArgs);
// having just type populates by type

@@ -134,2 +145,3 @@ A.isNotUndefined(req.globals['request-cache'].byType.bar);

Y.Env._attached['request-cache'] = false;
// This will override the "original" dispatcher

@@ -139,3 +151,6 @@ Y.use('request-cache');

Y.mojito.Dispatcher.dispatch({ instance: {} }, {
req: req
req: req,
page: {
staticAppConfig: this.CONFIG
}
});

@@ -145,2 +160,3 @@

A.isTrue(originalDispatcherCalled);
// And the cache is created

@@ -192,2 +208,3 @@ A.isObject(req.globals['request-cache'].byBase);

});
// If we have only base, use base

@@ -215,2 +232,3 @@ A.isTrue(this.baseCacheUsed);

});
// If we have only base, use base

@@ -238,2 +256,3 @@ A.isFalse(this.baseCacheUsed);

});
A.isTrue(this.__callIsUsed);

@@ -264,2 +283,3 @@ },

}
A.fail('An error should have been thrown earlier');

@@ -285,2 +305,3 @@ },

});
// Verify that only baz has been refreshed in the cache

@@ -287,0 +308,0 @@ A.isFalse(this.cache.byType.Bar.actionContext.baz.cached);

@@ -17,3 +17,4 @@ /*

var staticAppConfig,
refreshedAddons;
refreshedAddons,
enabled = true;

@@ -31,3 +32,4 @@ /**

var cache,
var config,
cache,
cachedResource,

@@ -38,3 +40,2 @@ newCommand,

i,
addonName,
addonInstance,

@@ -44,29 +45,40 @@ AddonConstuct,

// Build the cache if it doesn't exist.
adapter.req.globals = adapter.req.globals || {};
if (!staticAppConfig) {
if (!adapter.req.globals['request-cache']) {
adapter.req.globals['request-cache'] = {
byBase: {},
byType: {}
};
// Retrieve the cache configuration on the first dispatch.
staticAppConfig = adapter.page.staticAppConfig;
config = staticAppConfig['request-cache'] || {};
// The cache is enabled if you don't set the "enabled"
// property in the cache configuration, or if you set
// that property to a value that evaluates to "true".
if (config.hasOwnProperty('enabled')) {
enabled = !!config.enabled;
}
refreshedAddons = config.refreshAddons || [];
}
// Retrieve the cache and try to get a corresponding cached resource.
cache = adapter.req.globals['request-cache'];
cachedResource = (freshInstance.base && cache.byBase[freshInstance.base]) ||
(freshInstance.type && cache.byType[freshInstance.type]);
if (enabled) {
// Build the cache if it doesn't exist.
adapter.req.globals = adapter.req.globals || {};
if (!adapter.req.globals['request-cache']) {
adapter.req.globals['request-cache'] = {
byBase: {},
byType: {}
};
}
// Retrieve the cache and try to get a corresponding cached resource.
cache = adapter.req.globals['request-cache'];
cachedResource = (freshInstance.base && cache.byBase[freshInstance.base]) ||
(freshInstance.type && cache.byType[freshInstance.type]);
}
// If there is a cached resource, dispatch with that.
if (cachedResource) {
// If this is the first ever call to dispatch, we retrieve that list from the config
if (!refreshedAddons) {
staticAppConfig = adapter.page.staticAppConfig;
refreshedAddons = staticAppConfig['request-cache'] && staticAppConfig['request-cache'].refreshAddons;
if (!refreshedAddons) {
refreshedAddons = [];
}
}
// We reference this here just to easily refer

@@ -102,3 +114,2 @@ // to cachedResource.actionContext.command

// TODO: handle staticAppConfig.actionTimeout
// Handle the __call case

@@ -119,3 +130,3 @@ if (Y.Lang.isFunction(cachedResource.controller[newCommand.action])) {

// Handle controller timeout
if (adapter.page.staticAppConfig.actionTimeout) {
if (staticAppConfig.actionTimeout) {

@@ -147,3 +158,3 @@ // This will be cleared in ActionContext.done if it happens in time

}, adapter.page.staticAppConfig.actionTimeout);
}, staticAppConfig.actionTimeout);
}

@@ -150,0 +161,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc