Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matthewhudson/kash
Simple in-memory caching for JavaScript
https://github.com/matthewhudson/kash
cache caching caching-library dependency-free javascript nodejs npm-module
Last synced: 3 months ago
JSON representation
Simple in-memory caching for JavaScript
- Host: GitHub
- URL: https://github.com/matthewhudson/kash
- Owner: matthewhudson
- License: mit
- Created: 2013-11-19T17:55:33.000Z (about 11 years ago)
- Default Branch: main
- Last Pushed: 2023-06-09T13:56:59.000Z (over 1 year ago)
- Last Synced: 2024-10-10T14:46:25.827Z (3 months ago)
- Topics: cache, caching, caching-library, dependency-free, javascript, nodejs, npm-module
- Language: JavaScript
- Homepage:
- Size: 1.52 MB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.markdown
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# KASH 🚀🎉
[![NPM Version](https://img.shields.io/npm/v/kash.svg)](https://npmjs.com/package/kash)
[![Code Coverage](https://codecov.io/gh/matthewhudson/kash/branch/main/graph/badge.svg?token=dznrRZtztn)](https://codecov.io/gh/matthewhudson/kash)
[![Downloads](https://img.shields.io/npm/dt/kash.svg)](https://img.shields.io/npm/dt/kash.svg)
[![License](https://img.shields.io/npm/l/kash.svg)](https://img.shields.io/npm/l/kash.svg)## What? 🤔
Fast and simple in-memory caching. 🏎️💨
## Why? 🎯
Because sometimes you need straight-forward, reliable, and low-latency caching. ⚡
## Installation 📦
```sh
npm install kash
```And then import it:
```js
// using es modules
import kash from "kash";// common.js
const kash = require("kash");// AMD
// I've forgotten but it should work.
```Or use script tags and globals.
```html
```
And then grab it off the global like so:
```js
const kash = kash.default;
```## Synopsis 📖
```js
setTimeout(function() {
console.log(kash.get("foo"));
}, 101);kash.set("foo", "bar", 100);
console.log(kash.get("foo"));
```Will print the following in the console:
```sh
bar
null
```## API 🛠️
### kash.set(key, value [, expiration ])
Set a key with a value. Set expiration to remove from cache after the specified number of milliseconds. Defaults to 2000 ms.
### kash.get(key)
Retrieve the value for the specified key. Returns null if key does not exist.
### kash.del(key)
Deletes a key.
### kash.flush()
Removes the cache of all contents.
### kash.size()
Get the number of entries in the cache.
## Author
| [![twitter/matthewgh](http://gravatar.com/avatar/e0f8435a3df533d64b09b8aee394b8d3?s=85)](https://twitter.com/matthewgh "Follow @matthewgh on Twitter") |
| ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [Matthew Hudson](http://thematthewhudson.com/) | |