1.0.1 • Published 9 years ago

expirable-hash-table v1.0.1

Weekly downloads
14
License
MIT
Repository
github
Last release
9 years ago

expirable-hash-table

Expirable HashTable to enable timeout-based item removal from HashTable.

js-standard-style Build status

Install

npm install expirable-hash-table

Use

var ExpirableHashTable = require('expirable-hash-table')

var myTable = new ExpirableHashTable(1000) // default timeout in miliseconds

myTable.set('key', 'value', 3000) // optional timeout in miliseconds

myTable.get('key') // -> value
myTable.remove('key') // -> ExpirableHashTable
myTable.has('key') // -> true/false
myTable.purge() // -> ExpirableHashTable
myTable.toArray() // -> Array
myTable.size() // -> Integer

myTable.on('change', function() {
  // A change event is emitted ever time an item is added, updated or removed
})

myTable.once('<key>:expired', function() {
   // A expired event is emitted when a given item expires. Useful if a specific item wants to be monitored. 
})

License

MIT

1.0.1

9 years ago

1.0.0

9 years ago