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

js-memcache

v1.1.0

Published

Store data in memory for better performance by saving on network requests.

Downloads

12

Readme

JSMemcache Build Status npm version

Store data in memory for better performance by saving on network requests. (~600 bytes – minified and gzipped)

Installation

Using npm:

$ npm install js-memcache --save-dev

Using bower:

$ bower install js-memcache --save-dev

In browser:

JSMemcache is available via namespace JSMemcache in browsers' global scope i.e.

<script src="path/to/JSMemcache.js"></script>
<script>
  const jsMemcache = new JSMemcache(); // available via window.JSMemcache
  ...
</script>

In node / Using CommonJS:

JSMemcache can be setup in node as following i.e.

const JSMemcache = require('JSMemcache');
const jsMemcache = new JSMemcache();
...

Using AMD (RequireJS):

JSMemcache can be setup as following using RequireJS i.e.

require(['path/to/JSMemcache'], function(JSMemcache) {
  const jsMemcache = new JSMemcache();
  ...
});

API

JSMemcache exposes following API:

.setLimit(limit {int})

Set cache maximum limit. Default is set to 100 entries.

.setSeparator(separator {string})

Set a key separator for each entry in cache. Default is +.

.getLimit()

Get cache's current limit.

.getSeparator()

Get cache's current separator.

.getSize()

Get cache's current size.

.add(key {string|array}, value {mixed})

Add a new entry into cache as key value pair. Throws a TypeError if key is neither a string nor an array.

.get(key {string|array})

Get an entry by key from cache.

.update(key {string|array}, value {mixed})

Update an entry by key in cache. Throws a ReferenceError if key does not exist in cache.

.remove(key {string|array})

Remove an entry by key from cache. Throws a ReferenceError if key does not exist in cache.

.all()

Get list of all entries in cache.

.keys()

Get list of keys for all entries in cache.

.clear()

Clear all data in cache and remove all entries.

.set(key {string|array}, value {mixed})

An alias for .add()

.replace(key {string|array}, value {mixed})

An alias for .update()

Issues / Contributing

If you find an issue or wish to suggest any improvements then use the issue tracker to file an issue. Please provide as much possible details in there. Even better that you can submit a pull request for your issue if you already have a solution in mind.

Contribution is most welcome. To cotribute, fork the repository and branch out from master for your changes. Make sure you update/add tests. This repository uses the fantastic and super easy-to-use testing framework AVA. Once ready open a pull request.

https://github.com/jabranr/js-memcache

License

MIT License © 2016 – Jabran Rafique