# dictionaryttl

> A lightweight dictionary with TTL expiration. Based on Domenic Denicola's 'dict'

Latest version **1.0.3** (published 2014-08-10) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install dictionaryttl
pnpm add dictionaryttl
yarn add dictionaryttl
bun add dictionaryttl
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2014-08-10 |
| First published | 2014-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Cory Forsythe |
| Maintainers | coryforsythe |
| Keywords | dict, dictionary, map, string map, hash, ttl |

## Links

- npm: https://www.npmjs.com/package/dictionaryttl
- Repository: https://github.com/structuredambitionllc/dictionaryTTL
- Issues: https://github.com/structuredambitionllc/dictionaryTTL/issues
- npm.io page: https://npm.io/package/dictionaryttl

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2014-08-10
- 1.0.2 — 2014-08-10
- 1.0.1 — 2014-08-10
- 1.0.0 — 2014-08-10

## README

#dictionaryTTL
##### A Dictionary offering expiration of key-value pairs based on TTL.  Based on Domenic Denicola's dict. <https://github.com/domenic/dict>.  This module allows for expiring key-value pairs based on the TTL for each key. The TTL is evaluated when a get is called or the for-each iterator is accessed.


##Installation
```
npm install dictionaryttl
```

##Usage
```js
var dictionary = require("dictionaryttl");

var d = dictionary({
   key1: "value", //a string value example
   key2: {ik1: "value1", ik2:"value2"} // an object example
});

d.has("key1");                    // true
d.get("key1");                    // "value"
d.size;                           // 2
d.set("aNewKey", "aNewValue");

d.set("aNewTTLKey", "aNewValue",500);  //Set a new ttl key valid for 500 seconds. This pair will not be returned after 500 seconds by any get or iterator ops.

d.delete("key2");                    // true


d.forEach(function (value, key) {
   console.log("KeyValuePair: " + key + ": " + value);
});
d.clear();
d.size;                           // 0
```

---
_Source: https://npm.io/package/dictionaryttl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
