Comparing version 0.1.1 to 0.2.0
@@ -5,3 +5,2 @@ module.exports = function Cache(options) { | ||
var self = this, | ||
_ = require('underscore'), | ||
clone = require('clone'), | ||
@@ -77,5 +76,8 @@ hits = 0, | ||
var existingTimeoutId; | ||
if (durationSeconds === 0 && cachedItems.hasOwnProperty(key)) { | ||
existingTimeoutId = cachedItems[key].timeoutId; | ||
} | ||
durationSeconds = (durationSeconds) ? Math.max(1, durationSeconds) : 1; | ||
var expires = new Date(); | ||
expires.setTime(expires.getTime() + durationSeconds * 1000); | ||
@@ -89,3 +91,3 @@ if (Object.keys(cachedItems).length >= self.maxSize && | ||
// clear timeout on existing values | ||
if (cachedItems[key] !== undefined && cachedItems[key].timeoutId !== undefined) { | ||
if (cachedItems[key] !== undefined && cachedItems[key].timeoutId !== undefined && !existingTimeoutId) { | ||
clearTimeout(cachedItems[key].timeoutId); | ||
@@ -99,3 +101,3 @@ } | ||
lastAccessed: new Date(), | ||
timeoutId: setTimeout(function() { | ||
timeoutId: (existingTimeoutId) ? existingTimeoutId : setTimeout(function() { | ||
self.del(key); | ||
@@ -102,0 +104,0 @@ }, durationSeconds * 1000) |
@@ -7,5 +7,4 @@ { | ||
], | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"dependencies": { | ||
"underscore": "1.x.x", | ||
"clone": "0.1.x" | ||
@@ -15,4 +14,8 @@ }, | ||
"mocha": "1.x.x", | ||
"jshint": "0.6.x" | ||
"jshint": "2.x.x", | ||
"travis-cov": "0.x.x", | ||
"blanket": "1.x.x", | ||
"node-dependencies": "0.x.x", | ||
"coveralls": "2.x.x", | ||
"mocha-lcov-reporter": "0.x.x" | ||
}, | ||
@@ -32,4 +35,17 @@ "keywords": [ | ||
"scripts": { | ||
"test": "make test" | ||
} | ||
"test": "make test && make test-cov && make test-lcov | ./node_modules/coveralls/bin/coveralls.js" | ||
}, | ||
"config": { | ||
"blanket": { | ||
"pattern": "//^((?!/node_modules/)(?!/test/).)*$/ig", | ||
"onlyCwd": true, | ||
"data-cover-flags": { | ||
"branchTracking": true | ||
} | ||
}, | ||
"travis-cov": { | ||
"threshold": 100 | ||
} | ||
}, | ||
"license": "MIT" | ||
} |
@@ -1,3 +0,2 @@ | ||
eidetic | ||
=== | ||
# eidetic | ||
@@ -12,9 +11,31 @@ Eidetic is a NodeJS module that will cache JS values in memory. Features of the module include: | ||
[![Build Status](https://secure.travis-ci.org/mac-/eidetic.png)](http://travis-ci.org/mac-/eidetic) | ||
[![Coverage Status](https://coveralls.io/repos/mac-/eidetic/badge.png)](https://coveralls.io/r/mac-/eidetic) | ||
[![NPM version](https://badge.fury.io/js/eidetic.png)](http://badge.fury.io/js/eidetic) | ||
[![Dependency Status](https://david-dm.org/mac-/eidetic.png)](https://david-dm.org/mac-/eidetic) | ||
Installation | ||
=== | ||
[![NPM](https://nodei.co/npm/eidetic.png?downloads=true&stars=true)](https://nodei.co/npm/eidetic/) | ||
## Contributing | ||
This module makes use of a `Makefile` for building/testing purposes. After obtaining a copy of the repo, run the following commands to make sure everything is in working condition before you start your work: | ||
make install | ||
make test | ||
Before committing a change to your fork/branch, run the following commands to make sure nothing is broken: | ||
make test | ||
make test-cov | ||
Don't forget to bump the version in the `package.json` using the [semver](http://semver.org/spec/v2.0.0.html) spec as a guide for which part to bump. Submit a pull request when your work is complete. | ||
***Notes:*** | ||
* Please do your best to ensure the code coverage does not drop. If new unit tests are required to maintain the same level of coverage, please include those in your pull request. | ||
* Please follow the same coding/formatting practices that have been established in the module. | ||
## Installation | ||
npm install eidetic | ||
Usage | ||
=== | ||
## Usage | ||
@@ -27,3 +48,3 @@ The put method is used to store a value for a given key in the cache: | ||
* value - required, the value to store in the cache | ||
* durationSeconds - optional (default is 1), the number of seconds to hold the value in the cache | ||
* durationSeconds - optional (default is 1), the number of seconds to hold the value in the cache. If this is set to `0` AND there is already a value stored at the specified key, the value is updated without modifying the TTL. | ||
* useSlidingExpiration - optional (default is false), whether or not to refresh the expiration on a cache hit | ||
@@ -84,12 +105,4 @@ * returns true if the put was successful, false otherwise | ||
License | ||
=== | ||
The MIT License (MIT) Copyright (c) 2012 Mac Angell | ||
# License | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
The MIT License (MIT) |
{ | ||
// Settings | ||
"passfail" : false, // Stop on first error. | ||
"maxerr" : 100, // Maximum error before stopping. | ||
"bitwise": false, | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"es3": false, | ||
"forin": true, | ||
"immed": true, | ||
"indent": 0, | ||
"latedef": true, | ||
"newcap": false, | ||
"noarg": false, | ||
"noempty": true, | ||
"nonew": false, | ||
"plusplus": false, | ||
"quotmark": "single", | ||
"undef": true, | ||
"unused": true, | ||
"strict": false, | ||
"trailing": true, | ||
"maxparams": 0, | ||
"maxdepth": 0, | ||
"maxstatements": 0, | ||
"maxcomplexity": 0, | ||
"maxlen": 0, | ||
"asi": false, | ||
"boss": true, | ||
"debug": false, | ||
"eqnull": true, | ||
"esnext": false, | ||
"evil": false, | ||
"expr": false, | ||
"funcscope": false, | ||
"globalstrict": false, | ||
"iterator": false, | ||
"lastsemic": false, | ||
"laxbreak": false, | ||
"laxcomma": false, | ||
"loopfunc": true, | ||
"multistr": false, | ||
"proto": false, | ||
"smarttabs": false, | ||
"shadow": false, | ||
"sub": true, | ||
"supernew": false, | ||
"validthis": false, | ||
// Predefined globals whom JSHint will ignore. | ||
"browser" : false, // Standard browser globals e.g. `window`, `document`. | ||
"node" : true, | ||
"rhino" : false, | ||
"couch" : false, | ||
"wsh" : false, // Windows Scripting Host. | ||
"jquery" : false, | ||
"prototypejs" : false, | ||
"mootools" : false, | ||
"dojo" : false, | ||
"predef" : [ // Custom globals. | ||
//"exampleVar", | ||
//"anotherCoolGlobal", | ||
//"iLoveDouglas" | ||
], | ||
// Development. | ||
"debug" : false, // Allow debugger statements e.g. browser breakpoints. | ||
"devel" : true, // Allow developments statements e.g. `console.log();`. | ||
// ECMAScript 5. | ||
"es5" : true, // Allow ECMAScript 5 syntax. | ||
"strict" : false, // Require `use strict` pragma in every file. | ||
"globalstrict" : false, // Allow global "use strict" (also enables 'strict'). | ||
// The Good Parts. | ||
"asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons). | ||
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons. | ||
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.). | ||
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments. | ||
"curly" : true, // Require {} for every new block or scope. | ||
"eqeqeq" : true, // Require triple equals i.e. `===`. | ||
"eqnull" : false, // Tolerate use of `== null`. | ||
"evil" : false, // Tolerate use of `eval`. | ||
"expr" : false, // Tolerate `ExpressionStatement` as Programs. | ||
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`. | ||
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );` | ||
"latedef" : true, // Prohibit variable use before definition. | ||
"loopfunc" : true, // Allow functions to be defined within loops. | ||
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`. | ||
"regexp" : false, // Prohibit `.` and `[^...]` in regular expressions. | ||
"regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`. | ||
"scripturl" : true, // Tolerate script-targeted URLs. | ||
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`. | ||
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`. | ||
"undef" : true, // Require all non-global variables be declared before they are used. | ||
// Personal styling preferences. | ||
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`. | ||
"noempty" : true, // Prohibit use of empty blocks. | ||
"nonew" : true, // Prohibit use of constructors for side-effects. | ||
"nomen" : false, // Prohibit use of initial or trailing underbars in names. | ||
"onevar" : false, // Allow only one `var` statement per function. | ||
"plusplus" : false, // Prohibit use of `++` & `--`. | ||
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`. | ||
"trailing" : true, // Prohibit trailing whitespaces. | ||
"white" : false, // Check against strict whitespace and indentation rules. | ||
"indent" : 4 // Specify indentation spacing | ||
} | ||
"node": true, | ||
"browser": true | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
361
106
18320
7
1
- Removedunderscore@1.x.x
- Removedunderscore@1.13.7(transitive)