npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

remote-map-cache

v1.3.1

Published

A remote nodejs Cache Server, for you to have your perfect MAP Cache Saved and useable remotely. Easy Server and Client Creations, fast, stores the Cache before stopping and restores it again!

Downloads

4

Readme

remote-map-cache

A remote nodejs Cache Server, for you to have your perfect MAP Cache Saved and useable remotely. Easy Server and Client Creations, fast, stores the Cache before stopping and restores it again!

Installation

npm install https://github.com/Tomato6966/remote-map-cache
npm install remote-map-cache

Usage

  1. Create the Cache (which can be used as a DB TOO!) - Create a File-Folder-Project, at your CACHE SERVER and put in this Code:
const { remoteCacheServer } = require("remote-map-cache");

const Server = new remoteCacheServer({
    username: "TheUserNameForTheCacheServer",
    password: "ThePasswordForTheCacheServer",
    port: 4040, // Any port
    tls: true
});
// Following Events are optional
Server
    .on("serverReady", () => {
        console.log("DatabaseCacheServer ready and waiting for connections");
    })
    .on("serverError", (error) => {
        console.error("DatabaseCacheServer error, ERROR:\n", error, "\n---\n");
    })
    .on("serverClose", (reason) => {
        console.log("DatabaseCacheServer closed");
    })
    .on("serverConnect", (connection, payload) => {
        console.log("DatabaseCacheServer a Client Connected");
    })
    .on("serverDisconnect", (connection, reason) => {
        console.log("DatabaseCacheServer a Client Disconnected");
    })
    .on("serverMessage", (message) => {
        // console.log("DatabaseCacheServer, received a Message", message);
    })
    .on("serverRequest", async (request, response, client) => {
        // console.log("DatabaseCacheRequest, received a Request", request);
    });
  1. To connect the cache do this:
const { remoteCacheClient, remoteCacheServer } = require("remote-map-cache");
const client = new remoteCacheClient({
    username: "db_cache",
    password: "db_cache",
    host: "localhost",
    port: 5000,
    tls: true,
    // keyNotInCacheResponse: null, // optional I like to use "null";
})

// following events are optional
client
    .on("cacheReady", () => {
        console.log("DATABASECACHECLIENT ready and connected");
    })
    .on("cacheError", (error) => {
        console.error("DATABASECACHECLIENT error, ERROR:\n", error, "\n---\n");
    })
    .on("cacheClose", (reason) => {
        console.log("DATABASECACHECLIENT closed, REASON?:\n", reason, "\n---\n");
    })
    .on("cacheMessage", (message) => {
        console.log("message", message);
    })
    .on("cacheRequest", async (request, response, client) => {
        console.log("REQUEST", request);
    });

// example usage
async function yourProgram(){
    await client.set("hi", "bye").then(console.log).catch(console.error);
    await client.get("hi").then(console.log).catch(console.error);
    await client.set("array", []).then(console.log).catch(console.error);
    await client.push("array", "element").then(console.log).catch(console.error);
    await client.push("array", "element2").then(console.log).catch(console.error);
    await client.size().then(console.log).catch(console.error);
    await client.get("array").then(console.log).catch(console.error);
    await client.all().then(console.log).catch(console.error);
}

yourProgram();

Methods (Functions) for the CACHE-CLIENT(s)

  • get(key)
  • set(key)
  • add(key, amount)
  • push(key, element)
  • has(key)
  • delete(key)
  • clear() clears the whole cache Map
  • all() / values() array of all values
  • entries() array of [key, value]
  • keys() array of all keys
  • ping() shows the ping
  • size() shows the cache-map-size

Events for the CACHE-SERVER

  • serverReady shows when the server is ready, you don't need to listen to it!
  • serverError shows when the server errors, you don't need to listen to it!
  • serverClose shows when the server closes, you don't need to listen to it!
  • serverConnect shows when a client connects, you don't need to listen to it!
  • serverDisconnect shows when a client disconnects, you don't need to listen to it!
  • serverMessage receives messages from a cache-client, you don't need to listen to it!
  • serverRequest received requets from a cache-client, used for sending the cache datas, you don't need to listen to it!

Events for the CACHE-Client(s)

  • cacheReady shows when the server is ready, you don't need to listen to it!
  • cacheError shows when the server errors, you don't need to listen to it!
  • cacheClose shows when the server closes, you don't need to listen to it!
  • cacheMessage receives messages from the cache-server, you don't need to listen to it!
  • cacheRequest receives requets from the cache-server, you don't need to listen to it!