Skip to content

Commit de75a4a

Browse files
Update README.md
1 parent ac64e82 commit de75a4a

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
[![NPM Install Size][npm-install-size-image]][npm-install-size-url]
55
[![NPM Downloads][npm-downloads-image]][npm-downloads-url]
66

7-
Lrujs is a fast and lightweight least-recently-used cache for [Node.js](http://nodejs.org)
7+
Lrujs is a fast and lightweight lru (least-recently-used) caching library for javascript.
8+
9+
A LRU (least-recently-used) cache will automatically removes the least recently used data from cache when a new data is added to the cache and cache is full.
10+
11+
Lrujs support TTL (Time to live) and max cache size feature.
12+
The default value for maxSize is 1000 and TTL is 0 milliseconds (0 means permanently), if you not set the max cache size and ttl then the default values are used.
13+
14+
Lrujs is also support TTL, but it is not a TTL cache, and does not make strong TTL guarantees. Lrujs will not automatically removes the expired items, but you can set a default TTL on the cache or on a single value. If you do so, it will treat expired items as missing, and delete them when they are fetched. You can set TTL in milliseconds.
815

916
## Features
1017

@@ -52,14 +59,7 @@ cache.forEach(function (data) {
5259
});
5360
```
5461

55-
## Introduction
56-
57-
Lrujs is a fast and lightweight caching library for javascript, lrujs support TTL (Time to live) and max cache size feature.
58-
The default value for maxSize is 1000 and TTL is 0 milliseconds (0 means permanently), if you not set the max cache size and ttl then the default values are used.
59-
60-
Lrujs is also support TTL, but it is not a TTL cache, and does not make strong TTL guarantees. Lrujs will not automatically removes the expired items, but you can set a default TTL on the cache or on a single value. If you do so, it will treat expired items as missing, and delete them when they are fetched. You can set TTL in milliseconds.
61-
62-
#### Create a cache object:
62+
## Create a new cache object
6363

6464
```js
6565
const LRUCache = require("@opensnip/lrujs");
@@ -71,7 +71,7 @@ const cache = new LRUCache({
7171
});
7272
```
7373

74-
#### Set a new data:
74+
## Set a new data
7575

7676
In lrujs any value (both objects and primitive values) may be used as either a key or a value.
7777

@@ -83,7 +83,7 @@ cache.set("a", 10);
8383
cache.set("b", 10, { ttl: 200 }); // Expires after 200 ms
8484
```
8585

86-
#### Get data:
86+
## Get data from cache
8787

8888
```js
8989
// Add new data in cache
@@ -103,18 +103,18 @@ cache.get("a"); // undefined
103103
cache.get("b"); // undefined
104104

105105
// Set return value of get function
106-
cache.get("a", function (err, data) {
106+
cache.get("a", function (err, value) {
107107
if (err) return null;
108-
return data;
108+
return value;
109109
}); // undefined
110110

111-
cache.get("b", function (err, data) {
111+
cache.get("b", function (err, value) {
112112
if (err) return null;
113-
return data;
113+
return value;
114114
}); // null
115115
```
116116

117-
#### Check data exists in cache
117+
## Check data exists in cache
118118

119119
```js
120120
// Add new data in cache
@@ -125,21 +125,21 @@ cache.has("a"); // true
125125
cache.has("b"); // false
126126
```
127127

128-
#### Delete data:
128+
## Delete data from cache
129129

130130
```js
131131
// Delete data
132132
cache.delete("a");
133133
```
134134

135-
#### Delete all data from cache:
135+
## Delete all data from cache
136136

137137
```js
138138
// Delete all data
139139
cache.clear();
140140
```
141141

142-
#### Get all data from cache:
142+
## Get all data from cache
143143

144144
```js
145145
// Add new data in cache

0 commit comments

Comments
 (0)