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

nope-redis

v1.3.3

Published

Simple & Fast Node.JS memory caching

Downloads

13

Readme

nope-redis

Simple & Fast Node.JS memory caching

  • Support: object, array, string, integer, boolean, hex store, function, WHAT YOU WANT.
  • Full-featured: A simple caching system with setItem, getItem, and deleteItem methods, designed to function similar to Redis. Keys in this system can have a specified timeout (ttl), after which they expire and are automatically deleted from the cache. All keys are stored within a single object, so the practical limit is approximately 1 million keys.

Prerequisite:

  • Node.js, at least v12 >

Examples:

Initialize (INIT):

const nopeRedis = require("nope-redis");

Store a key (setItem):

Sets a key value pair. It is possible to define a ttl (in seconds). Returns true on success.

let obj = { name: "orhan", age: 26 };
 
result = nopeRedis.setItem("user1", obj,  10 );
// true

Retrieve a key (getItem):

Gets a saved value from the cache. Returns a null if not found or expired. If the value was found it returns the value.

result = nopeRedis.getItem("user1");
if(!result){
	// no data
}
// { name: "orhan", age: 26 }

Delete a key (deleteItem):

Delete a key. Returns the true or false.

result = nopeRedis.deleteItem("user1");
// true

Retrieve stats of key (itemStats):

It is used to get statistics and general information of a key.

result = nopeRedis.itemStats("user1");
if(!result){
	// no data
}
// { expires_at: 789541503 , remaining_seconds: 260, hit: 1995 }

Flush all keys (flushAll)

Flush all data.

result = nopeRedis.flushAll();
// true

Stop Service (SERVICE_KILL)

Stops the "nope-redis" service.

result = nopeRedis.SERVICE_KILL();
// true

Start SERVICE (SERVICE_START)

Start the "nope-redis" service. IT STARTS AUTOMATICALLY BY DEFAULT. YOU DON'T NEED THIS. JUST USE WHEN YOU "SERVICE_KILL"

result = nopeRedis.SERVICE_START();
// true

Store Statistics (stats)

Returns the statistics and information.

result = nopeRedis.stats({ showKeys: true, showTotal: true, showSize: true });
/*
		{
		    "status": true,
			"killerIsFinished": true,
			"lastKiller": 1647245881,
			"nextKiller": 1647245886,
			"criticalError": 0,
			"totalHits": 0,
			"total": 0,
			"keys": [],
			"size": "0 bytes"
		}
*/
  • status: nope-redis service status.
  • killerIsFinished: The ttl value indicates whether the function is finished deleting obsolete values.
  • lastKiller: The unix timestamp value of the last time old values were deleted.
  • nextKiller: The unix timestamp value when it will delete old values.
  • criticalError: is the value of how many times it gets critical errors and therefore how many times it reboots itself "nope-redis".
  • totalHits: global total hits (total get item count)
  • total: Key count
  • keys: Array of all existing keys.
  • size: Value size count in approximately file size (Bytes, KB, MB, GB, TB)

Bencmark:

  • MacBook Pro 2015 i5 2,3 GHz 8 GB,
  • Node.JS v16.10.0

| TEST | total set/get | seconds | | ------------ | ------------ | ------------ | | setItem | 1 | 137 μs (0 s + 136603 ns) | | getItem | 1 | ~44 μs (0 s + 43732 ns) |

| TEST | total set/get | seconds | | ------------ | ------------ | ------------ | | setItem | 250.000 | 148 ms (0 s + 147908556 ns) | | getItem | 250.000 | ok ~69 ms (0 s + 69199889 ns) |

The second it takes in total to set or get 250.000 records.

Notes:

  • key must be string,
  • default ttl is 30 seconds
  • If you activate memoryStats calculation, it will operate every 1 hour.
  • Data that is due for deletion is purged in bulk every 5 seconds.
  • On average, it consumes around 6-7 MB when idle. (Node Process include.)