Skip to content

Commit

Permalink
Updating LRU & router, adding cacheTTL configuration option for…
Browse files Browse the repository at this point in the history
… `etag` & `routes` caches, changing assignment of `obj.etags.cache.update` to rely on `typeof x === "function"` evaluating as `true`
  • Loading branch information
avoidwork committed Dec 28, 2017
1 parent 88c48ba commit 28c35e3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 50 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ This is a sample configuration for Tensō, without authentication or SSL. This w
```
{
"auth": {}, /* Optional, see Authentication section */
"cacheSize": 1000, /* Optional, size of Etag LRU cache */
"cacheSize": 1000, /* Optional, size of Etag & route LRU caches */
"cacheTTL": 0, /* Optional, TTL of items in Etag & route LRU caches */
"coerce": true, /* Optional - coerces query string parameters to primitives, enabled by default */
"compress": false, /* Optional, enabled by default */
"headers": {}, /* Optional, custom headers */
Expand Down
1 change: 1 addition & 0 deletions lib/tenso.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Tenso extends HTTPMethods {
address: "0.0.0.0",
default: "localhost",
cacheSize: 1000,
cacheTTL: 0,
catchAll: true,
coerce: true,
compress: true,
Expand Down
4 changes: 3 additions & 1 deletion lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,17 +558,19 @@ function bootstrap (obj) {

obj.etags = etag({
cacheSize: obj.config.cacheSize,
cacheTTL: obj.config.cacheTTL,
seed: obj.config.seed,
notify: obj.config.etags.notify,
onchange: obj.config.etags.onchange
});

if (obj.config.etags.update !== void 0) {
if (typeof obj.config.etags.update === "function") {
obj.etags.cache.update = obj.config.etags.update;
}

obj.router = woodland({
cacheSize: obj.config.cacheSize,
cacheTTL: obj.config.cacheTTL,
coerce: obj.config.coerce,
defaultHeaders: obj.config.headers,
http2: obj.config.http2,
Expand Down
85 changes: 41 additions & 44 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tenso",
"description": "Tensō is an elastic REST API gateway for node.js",
"version": "6.2.11",
"version": "6.3.0",
"homepage": "http://avoidwork.github.io/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand Down Expand Up @@ -45,12 +45,12 @@
"precise": "^1.1.0",
"retsu": "^3.0.1",
"tiny-coerce": "^1.0.1",
"tiny-etag": "^1.3.13",
"tiny-etag": "^1.4.0",
"tiny-merge": "^1.0.0",
"tiny-uuid4": "^1.0.1",
"tiny-xml": "^1.0.6",
"uws": "^9.14.0",
"woodland": "^4.2.5",
"woodland": "^4.3.0",
"yamljs": "^0.3.0"
},
"devDependencies": {
Expand All @@ -62,7 +62,7 @@
"grunt-nsp": "^2.3.1",
"jsonwebtoken": "^8.1.0",
"mocha": "^4.0.1",
"tiny-httptest": "^1.0.9"
"tiny-httptest": "^1.0.12"
},
"keywords": [
"rest",
Expand Down

0 comments on commit 28c35e3

Please sign in to comment.