All Projects → vaneenige → Unvault

vaneenige / Unvault

Licence: mit
📦 A minimal layer for node that allows results of time-consuming tasks to be stored.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Unvault

Orbit Db Http Api
A HTTP API Server for the OrbitDB distributed peer-to-peer database
Stars: ✭ 17 (-73.02%)
Mutual labels:  api, server
Gophergameserver
🏆 Feature packed, easy-to-use game server API for Go back-ends and Javascript clients. Tutorials and examples included!
Stars: ✭ 61 (-3.17%)
Mutual labels:  api, server
Go Bootstrap
Easy way to bootstrap a web server in Go (Routing|Middleware|Https)
Stars: ✭ 27 (-57.14%)
Mutual labels:  server, routing
Impress
Enterprise application server for Node.js and Metarhia private cloud ⚡
Stars: ✭ 634 (+906.35%)
Mutual labels:  api, server
Omdb Graphql Wrapper
🚀 GraphQL wrapper for the OMDb API
Stars: ✭ 45 (-28.57%)
Mutual labels:  api, server
Build
TeaWeb-可视化的Web代理服务。DEMO: http://teaos.cn:7777
Stars: ✭ 656 (+941.27%)
Mutual labels:  api, server
Kitura
A Swift web framework and HTTP server.
Stars: ✭ 7,533 (+11857.14%)
Mutual labels:  server, routing
Awesome Openapi3
😎 A list of awesome projects related to OpenAPI 3.0.x, curated by the community
Stars: ✭ 469 (+644.44%)
Mutual labels:  api, server
Ins sandstorm
[INS] Config setting for our sandstorm server
Stars: ✭ 61 (-3.17%)
Mutual labels:  api, server
Dito
Dito.js is a declarative and modern web framework with a focus on API driven development, based on Objection.js, Koa.js and Vue.js – Released in 2018 under the MIT license, with support by Lineto.com
Stars: ✭ 44 (-30.16%)
Mutual labels:  api, server
Spock
Another Haskell web framework for rapid development
Stars: ✭ 623 (+888.89%)
Mutual labels:  api, server
Sechub
SecHub - one central and easy way to use different security tools with one API/Client
Stars: ✭ 52 (-17.46%)
Mutual labels:  api, server
Ponzu
Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
Stars: ✭ 5,373 (+8428.57%)
Mutual labels:  api, server
Deno Drash
A REST microframework for Deno's HTTP server with zero 3rd party dependencies.
Stars: ✭ 795 (+1161.9%)
Mutual labels:  api, server
Koop
🔮 Transform, query, and download geospatial data on the web.
Stars: ✭ 505 (+701.59%)
Mutual labels:  api, server
Orion Core
The next generation Terraria Server API.
Stars: ✭ 28 (-55.56%)
Mutual labels:  api, server
Fastd
🚀 A high performance PHP API framework.
Stars: ✭ 423 (+571.43%)
Mutual labels:  api, server
New Website
🖥 cdnjs.com website
Stars: ✭ 449 (+612.7%)
Mutual labels:  api, server
Nodemcu Espress
Ultra-Lightweight and modular Node.js express like http server for NodeMCU. web - ESP8266
Stars: ✭ 39 (-38.1%)
Mutual labels:  api, server
Yii2 Nested Rest
Nested routing support to the Yii RESTful API framework
Stars: ✭ 45 (-28.57%)
Mutual labels:  api, routing

Unvault

Unvault is a minimal layer for node that allows results of time-consuming tasks to be stored. Improved performance is achieved by adding trackers that periodically update the layer, so that stored responses can be served instantly once requested. Also available as middleware.

npm travis

Features:

  • Insert key based trackers
  • Automatic and manual update
  • Support for async and await
  • Fast (without dependencies)
  • Small wrapper extending Map
  • Support for multiple stores

Install

$ npm install --save unvault

Note: Node 7.6.0 is required for async and await!

Usage

const unvault = require("unvault");

const store = unvault();

store.insert("random", 1000, () => Math.random());

const { value } = store.get("random");

TypeScript

import * as unvault from "unvault";

const store: Unvault = unvault();

Manual

Periodic updates might not suit your application's needs. Unvault supports a manual mode that provides more control over which trackers receive an update and when. Trackers with an interval of 0 will only run once. Both automatic and manual trackers allow for an update trigger.

store.insert("random", 0, () => Math.random());

store.trigger("random");

Advanced

Unvault can be combined with a node servers like Polka or Express to quickly deliver stored content to users. Trackers also work with async and await for asynchronous updates. Store your external fetch responses, database results and other in the vault for faster response times.

const polka = require("polka");
const unvault = require("unvault");
const fetch = require("node-fetch");

const server = polka();
server.listen(3000);

const route = "/api/fetch";
const routes = unvault();

routes.insert(route, 2000, async () => {
  const response = await fetch(
    "https://api.github.com/repos/vaneenige/unvault"
  );
  return response.json();
});

server.get(route, (req, res) => {
  const { value } = routes.get(route);
  server.send(res, 200, value, "application/json");
});

API

.insert(key, interval, update, options)

Inserts a tracker into the vault.

Returns: Result of update function (use await for async updates).

.trigger(key)

Manually runs a tracker.

Returns: Result of update function (use await for async updates).

.prototype

As unvault extends Map, all of its functions are available: clear(), delete(key), entries() and more!

Note: The update callback will receive the key as a parameter. Providing a lifetime variable (in ms) to the options object will delete the tracker and stop its automatic updates once it runs out.

Benchmarks

For this benchmark an example route is setup that searches a mongodb collection that contains 100 nodes. The node server is started with node v9.0.0 and results are documented after a single warm-up run.

The benchmarking tool for results is the following:

$ wrk -t8 -c100 -d10s http://localhost:3000/:type/mongo

Without unvault

Thread Stats   Avg      Stdev     Max   +/- Stdev
  Latency    44.23ms    8.44ms  80.36ms   65.70%
  Req/Sec   271.83     26.52   353.00     64.25%
21755 requests in 10.07s, 209.77MB read

Requests/sec:   2160.05
Transfer/sec:     20.83MB

With unvault

Thread Stats   Avg      Stdev     Max   +/- Stdev
  Latency     4.89ms  391.21us   9.38ms   92.94%
  Req/Sec     2.47k   341.17     9.22k    99.75%
196758 requests in 10.10s, 1.85GB read

Requests/sec:  19481.54
Transfer/sec:    187.85MB

Note: Unvault aims to reduce the time spend creating a response. If the process normally takes a second to finish this solution will eliminate most of that second.

License

MIT © Colin van Eenige

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].