1.9.2 • Published 1 year ago

es-cache v1.9.2

Weekly downloads
50
License
GPL-3.0
Repository
github
Last release
1 year ago

es-cache

A simple in-memory cache on ecmascript 6 and typescript.

Installation

npm install es-cache

Usage

var Cache = require('es-cache');
var cache = new Cache();

// now just use the cache

cache.put('foo', 'bar');
console.log(cache.get('foo'))

// that wasn't too interesting, here's the good part

cache.put('houdini', 'disappear', 100) // Time in ms
console.log('Houdini will now ' + cache.get('houdini'));

setTimeout(function() {
  console.log('Houdini is ' + cache.get('houdini'));
}, 200);

which should print

bar
Houdini will now disappear
Houdini is null

API

put = function(key, value, time, callback)

  • Simply stores a value
  • If value is a function then function returned value is cached.
  • If time isn't passed in, it is stored forever
  • If time is passed then value is refreshed after the specified time using the specified function. Will actually remove the value in the specified time in ms (via setTimeout)
  • executes the callback function when value is removed.
  • Returns the cached value

get = function(key)

  • Retrieves a value for a given key
  • If value isn't cached, returns null

del = function(key)

  • Deletes a key, returns a boolean specifying whether or not the key was deleted

clear = function()

  • Deletes all keys

size = function()

  • Returns the current number of entries in the cache

keys = function()

  • Returns all the cache keys

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Send me a pull request.
1.9.2

1 year ago

1.9.1

1 year ago

1.9.0

2 years ago

1.8.5

2 years ago

1.8.4

2 years ago

1.8.2

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.7.2

2 years ago

1.8.3

2 years ago

1.6.0

3 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.2

3 years ago

1.2.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.41

5 years ago

1.0.40

6 years ago

1.0.39

6 years ago

1.0.38

6 years ago

1.0.37

6 years ago

1.0.36

6 years ago

1.0.35

6 years ago

1.0.34

6 years ago

1.0.33

6 years ago

1.0.32

6 years ago

1.0.31

7 years ago

1.0.30

7 years ago

1.0.29

7 years ago

1.0.28

7 years ago

1.0.27

7 years ago

1.0.26

7 years ago

1.0.25

7 years ago

1.0.24

8 years ago

1.0.23

8 years ago

1.0.22

8 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago

1.0.17

8 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.1.1

10 years ago

0.1.0

10 years ago