0.0.15 • Published 2 years ago

cachemuni v0.0.15

Weekly downloads
-
License
ISC
Repository
-
Last release
2 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

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago