Skip to content

Commit

Permalink
Version 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
radixxko committed Oct 4, 2018
1 parent 71d5ad7 commit c231efb
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 69 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
[![Version npm](https://img.shields.io/npm/v/liqd-cache.svg)](https://www.npmjs.com/package/liqd-cache)
[![Build Status](https://travis-ci.org/radixxko/liqd-cache.svg?branch=master)](https://travis-ci.org/radixxko/liqd-cache)
[![Coverage Status](https://coveralls.io/repos/github/radixxko/liqd-cache/badge.svg?branch=master)](https://coveralls.io/github/radixxko/liqd-cache?branch=master)
[![NPM downloads](https://img.shields.io/npm/dm/liqd-cache.svg)](https://www.npmjs.com/package/liqd-cache)
[![Known Vulnerabilities](https://snyk.io/test/github/radixxko/liqd-cache/badge.svg?targetFile=package.json)](https://snyk.io/test/github/radixxko/liqd-cache?targetFile=package.json)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4 changes: 2 additions & 2 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ module.exports = class Cache
}
}

delete( id )
delete( id, expire = true )
{
let item = this.cache.get( id );

if( item )
{
this.cache.delete( id );

if( item.expire_callback )
if( item.expire_callback && expire )
{
item.expire_callback( id,item.data );
}
Expand Down
153 changes: 88 additions & 65 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "liqd-cache",
"description": "Cache Library",
"version": "1.0.0",
"version": "1.0.1",
"author": "radixxko",
"license": "MIT",
"main": "lib/cache.js",
Expand All @@ -24,7 +24,7 @@
"liqd-timer": "^1.0.0"
},
"devDependencies": {
"coveralls": "^3.0.0",
"coveralls": "^3.0.2",
"mocha": "^5.0.4",
"nyc": "^11.6.0"
}
Expand Down
10 changes: 10 additions & 0 deletions test/tests/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,14 @@ describe('- cache', function()

setTimeout( done, 250 );
});

it('should not trigger expire', function( done )
{
let cache = new Cache();

cache.set('foo', 'bar', 1000, assert.fail );
cache.delete('foo', false);

setTimeout( done, 250 );
});
});

0 comments on commit c231efb

Please sign in to comment.