Security News
How Threat Actors are Abusing GitHub’s File Upload Feature to Host Malware
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
Readme
hashlru inspired
hashlru is the Simpler, faster LRU cache algorithm. Please checkout algorithm and complexity on hashlru.
ylru extends some features base on hashlru:
null
, undefined
, ''
, 0
const LRU = require('ylru');
const lru = new LRU(100);
lru.set(key, value);
lru.get(key);
// value2 will be expired after 5000ms
lru.set(key2, value2, { maxAge: 5000 });
// get key and update expired
lru.get(key2, { maxAge: 5000 });
initialize a lru object.
{Number} options.maxAge
: update expire time when get, value will become undefined
after maxAge
pass.Returns the value in the cache.
{Number} options.maxAge
: value will become undefined
after maxAge
pass.
If maxAge
not set, value will be never expired.Set the value for key.
Get all unexpired cache keys from lru, due to the strategy of ylru, the keys
' length may greater than max
.
const lru = new LRU(3);
lru.set('key 1', 'value 1');
lru.set('key 2', 'value 2');
lru.set('key 3', 'value 3');
lru.set('key 4', 'value 4');
lru.keys(); // [ 'key 4', 'key 1', 'key 2', 'key 3']
// cache: {
// 'key 4': 'value 4',
// }
// _cache: {
// 'key 1': 'value 1',
// 'key 2': 'value 2',
// 'key 3': 'value 3',
// }
reset a lru object.
const lru = new LRU(3);
lru.set('key 1', 'value 1');
lru.set('key 2', 'value 2');
lru.set('key 3', 'value 3');
lru.set('key 4', 'value 4');
lru.reset();
// cache: {
// }
// _cache: {
// }
lru.keys().length === 0;
dominictarr | fengmk2 | dead-horse | mourner | vagusX | RaoHai |
---|
This project follows the git-contributor spec, auto updated at Wed Mar 16 2022 23:57:13 GMT+0800
.
FAQs
Extends LRU base on hashlru
The npm package ylru receives a total of 1,196,890 weekly downloads. As such, ylru popularity was classified as popular.
We found that ylru demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.