Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to newer lru-cache #769

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ Node's `lru-cache` library:

```javascript
let ejs = require('ejs'),
LRU = require('lru-cache');
ejs.cache = LRU(100); // LRU cache with 100-item limit
{ LRUCache } = require('lru-cache');
ejs.cache = LRUCache(100); // LRU cache with 100-item limit
```

If you want to clear the EJS cache, call `ejs.clearCache`. If you're using the
Expand Down
4 changes: 2 additions & 2 deletions benchmark/bench-ejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function log(name, runTimes, totalLoops) {
}

function benchRender(name, file, data, opts, benchOpts) {
ejs.cache.reset();
ejs.cache.clear();
var runTimes = [];
opts = opts || {};
benchOpts = benchOpts || {};
Expand All @@ -133,7 +133,7 @@ function benchRender(name, file, data, opts, benchOpts) {
}

function benchCompile(name, file, opts, benchOpts) {
ejs.cache.reset();
ejs.cache.clear();
var runTimes = [];
opts = opts || {};
benchOpts = benchOpts || {};
Expand Down
2 changes: 1 addition & 1 deletion docs/jsdoc/cache.jsdoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
* Erases the entire cache. Called by {@link module:ejs.clearCache}
*
* @function
* @name Cache#reset
* @name Cache#clear
*/
4 changes: 2 additions & 2 deletions lib/ejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ exports.renderFile = function () {
};

/**
* Clear intermediate JavaScript cache. Calls {@link Cache#reset}.
* Clear intermediate JavaScript cache. Calls {@link Cache#clear}.
* @public
*/

Expand All @@ -503,7 +503,7 @@ exports.renderFile = function () {
exports.Template = Template;

exports.clearCache = function () {
exports.cache.reset();
exports.cache.clear();
};

function Template(text, optsParam) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ exports.cache = {
remove: function (key) {
delete this._data[key];
},
reset: function () {
clear: function () {
this._data = {};
}
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"eslint": "^6.8.0",
"git-directory-deploy": "^1.5.1",
"jsdoc": "^4.0.2",
"lru-cache": "^4.0.1",
"lru-cache": "^10.0.1",
"mocha": "^10.2.0",
"uglify-js": "^3.3.16"
},
Expand Down
2 changes: 1 addition & 1 deletion test/ejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var fs = require('fs');
var read = fs.readFileSync;
var assert = require('assert');
var path = require('path');
var LRU = require('lru-cache');
var { LRUCache : LRU } = require('lru-cache');
let lf = process.platform !== 'win32' ? '\n' : '\r\n';

try {
Expand Down
4 changes: 2 additions & 2 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ function encode_char(c) {
assert.ok(utils.cache.get('key')===undefined);
});
});
suite('unit testing function \'reset\' of object \'cache\'', function () {
suite('unit testing function \'clear\' of object \'cache\'', function () {
test('it should be callable without parameters', function () {
assert.doesNotThrow(() => { utils.cache.reset(); });
assert.doesNotThrow(() => { utils.cache.clear(); });
});
});
});
Expand Down