0.1.1 • Published 2 years ago

@sempervirens/cacher v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Sempervirens Cacher

A way to cache HTML pages in a MongoDB database.

Tests badge Version badge Version badge

Installation

npm i @sempervirens/dao

Usage

  1. Configure the Sempervirens DAO.

  2. When a request comes to the server for a page for the first time, get the full URL and HTML to be returned.

  3. Cache the page to the database with Sempervirens Cacher.

  4. When a request comes to the server for the page again, return the HTML from the database rather than re-rendering it.

API

url is a unique key.

create

Returns a record. If the record already exists, instead of re-rendering the HTML, it returns the existing HTML from the database.

PropTypeDescription
urlstringRequired. The full URL from a request for an HTML page resource.
htmlstringRequired. The complete HTML body to be returned in the response.

find

Returns a record that matches the URL.

PropTypeDescription
urlstringRequired. Finds a record by URL.

clear

If url is given, it clears only the record for the given URL. Otherwise, it clears all records.

PropTypeDescription
urlstringOptional. Clears the record with the given URL.