0.0.15 • Published 3 years ago

cachemuni v0.0.15

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

cachemuni

Overview

cachemuni makes it easy to cache/invalidate HTTP endpoints in nodejs.

Example usage

const express = require("express");
const { HttpCachingServer } = require("cachemuni");
const app = express();
const port = 3000;

app.get("/", (req, res) => {
  res.send("Hello World!");
});

app.post("/invalidate", (req, res) => {
  res.send("cache invalidated");
});

app.listen(port);

const cachingServer = new HttpCachingServer({
  targetHostName: "localhost",
  targetPort: 3000,
  config: {
    "/": {
      invalidateOn: ["POST /invalidate"],
    },
  },
});

cachingServer.listen(3001);

API

HttpCachingServer

HttpCachingServer is the same as http's Server object except the constructor takes in:

{
    targetHostName: string;
    targetPort: number;
    store?: Store;
    config?: Record<string, { invalidateOn?: string[] }>;
    serverOptions?: http.ServerOptions;
    considerHeaders?: string;
  }

Store

Store is a basic key/value string store which supports async. You can use a persisted store (redis, psql, etc.) or just a basic in memory store. If you do not pass an option, it defaults to a basic in memory store.

{
  get(k: string): Promise<string>;
  set(k: string, v: string): Promise<this>;
  remove(k: string): Promise<this>;
}
0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago