mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
docs:更新文档
This commit is contained in:
22
node_modules/ylru/History.md
generated
vendored
Normal file
22
node_modules/ylru/History.md
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
1.2.1 / 2018-07-11
|
||||
==================
|
||||
|
||||
**others**
|
||||
* [[`475abb0`](http://github.com/node-modules/ylru/commit/475abb0e9c787fd65d7c3dd3d2d74d67560b0bec)] - perf: only call Date.now() when necessary (#3) (Yiyu He <<dead_horse@qq.com>>)
|
||||
|
||||
1.2.0 / 2017-07-18
|
||||
==================
|
||||
|
||||
* feat: support lru.keys (#2)
|
||||
|
||||
1.1.0 / 2017-07-04
|
||||
==================
|
||||
|
||||
* feat: support get with maxAge (#1)
|
||||
|
||||
1.0.0 / 2016-12-29
|
||||
==================
|
||||
|
||||
* init version
|
||||
|
||||
23
node_modules/ylru/LICENSE
generated
vendored
Normal file
23
node_modules/ylru/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Copyright (c) 2016 node-modules
|
||||
Copyright (c) 2016 'Dominic Tarr'
|
||||
|
||||
Permission is hereby granted, free of charge,
|
||||
to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify,
|
||||
merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom
|
||||
the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
||||
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
91
node_modules/ylru/README.md
generated
vendored
Normal file
91
node_modules/ylru/README.md
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
# ylru
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[![build status][travis-image]][travis-url]
|
||||
[![Test coverage][codecov-image]][codecov-url]
|
||||
[![David deps][david-image]][david-url]
|
||||
[![Known Vulnerabilities][snyk-image]][snyk-url]
|
||||
[![npm download][download-image]][download-url]
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/ylru.svg?style=flat-square
|
||||
[npm-url]: https://npmjs.org/package/ylru
|
||||
[travis-image]: https://img.shields.io/travis/node-modules/ylru.svg?style=flat-square
|
||||
[travis-url]: https://travis-ci.org/node-modules/ylru
|
||||
[codecov-image]: https://img.shields.io/codecov/c/github/node-modules/ylru.svg?style=flat-square
|
||||
[codecov-url]: https://codecov.io/github/node-modules/ylru?branch=master
|
||||
[david-image]: https://img.shields.io/david/node-modules/ylru.svg?style=flat-square
|
||||
[david-url]: https://david-dm.org/node-modules/ylru
|
||||
[snyk-image]: https://snyk.io/test/npm/ylru/badge.svg?style=flat-square
|
||||
[snyk-url]: https://snyk.io/test/npm/ylru
|
||||
[download-image]: https://img.shields.io/npm/dm/ylru.svg?style=flat-square
|
||||
[download-url]: https://npmjs.org/package/ylru
|
||||
|
||||
**hashlru inspired**
|
||||
|
||||
[hashlru](https://github.com/dominictarr/hashlru) is the **Simpler, faster LRU cache algorithm.**
|
||||
Please checkout [algorithm](https://github.com/dominictarr/hashlru#algorithm) and [complexity](https://github.com/dominictarr/hashlru#complexity) on hashlru.
|
||||
|
||||
ylru extends some features base on hashlru:
|
||||
|
||||
- cache value can be **expired**.
|
||||
- cache value can be **empty value**, e.g.: `null`, `undefined`, `''`, `0`
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
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 });
|
||||
```
|
||||
|
||||
### API
|
||||
|
||||
## LRU(max) => lru
|
||||
|
||||
initialize a lru object.
|
||||
|
||||
### lru.get(key[, options]) => value | null
|
||||
|
||||
- `{Number} options.maxAge`: update expire time when get, value will become `undefined` after `maxAge` pass.
|
||||
|
||||
Returns the value in the cache.
|
||||
|
||||
### lru.set(key, value[, options])
|
||||
|
||||
- `{Number} options.maxAge`: value will become `undefined` after `maxAge` pass.
|
||||
If `maxAge` not set, value will be never expired.
|
||||
|
||||
Set the value for key.
|
||||
|
||||
### lru.keys()
|
||||
|
||||
Get all unexpired cache keys from lru, due to the strategy of ylru, the `keys`' length may greater than `max`.
|
||||
|
||||
```js
|
||||
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',
|
||||
// }
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
106
node_modules/ylru/index.js
generated
vendored
Normal file
106
node_modules/ylru/index.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
'use strict';
|
||||
|
||||
class LRU {
|
||||
constructor(max) {
|
||||
this.max = max;
|
||||
this.size = 0;
|
||||
this.cache = new Map();
|
||||
this._cache = new Map();
|
||||
}
|
||||
|
||||
get(key, options) {
|
||||
let item = this.cache.get(key);
|
||||
const maxAge = options && options.maxAge;
|
||||
// only call Date.now() when necessary
|
||||
let now;
|
||||
function getNow() {
|
||||
now = now || Date.now();
|
||||
return now;
|
||||
}
|
||||
if (item) {
|
||||
// check expired
|
||||
if (item.expired && getNow() > item.expired) {
|
||||
item.expired = 0;
|
||||
item.value = undefined;
|
||||
} else {
|
||||
// update expired in get
|
||||
if (maxAge !== undefined) {
|
||||
const expired = maxAge ? getNow() + maxAge : 0;
|
||||
item.expired = expired;
|
||||
}
|
||||
}
|
||||
return item.value;
|
||||
}
|
||||
|
||||
// try to read from _cache
|
||||
item = this._cache.get(key);
|
||||
if (item) {
|
||||
// check expired
|
||||
if (item.expired && getNow() > item.expired) {
|
||||
item.expired = 0;
|
||||
item.value = undefined;
|
||||
} else {
|
||||
// not expired, save to cache
|
||||
this._update(key, item);
|
||||
// update expired in get
|
||||
if (maxAge !== undefined) {
|
||||
const expired = maxAge ? getNow() + maxAge : 0;
|
||||
item.expired = expired;
|
||||
}
|
||||
}
|
||||
return item.value;
|
||||
}
|
||||
}
|
||||
|
||||
set(key, value, options) {
|
||||
const maxAge = options && options.maxAge;
|
||||
const expired = maxAge ? Date.now() + maxAge : 0;
|
||||
let item = this.cache.get(key);
|
||||
if (item) {
|
||||
item.expired = expired;
|
||||
item.value = value;
|
||||
} else {
|
||||
item = {
|
||||
value,
|
||||
expired,
|
||||
};
|
||||
this._update(key, item);
|
||||
}
|
||||
}
|
||||
|
||||
keys() {
|
||||
const cacheKeys = new Set();
|
||||
const now = Date.now();
|
||||
|
||||
for (const entry of this.cache.entries()) {
|
||||
checkEntry(entry);
|
||||
}
|
||||
|
||||
for (const entry of this._cache.entries()) {
|
||||
checkEntry(entry);
|
||||
}
|
||||
|
||||
function checkEntry(entry) {
|
||||
const key = entry[0];
|
||||
const item = entry[1];
|
||||
if (entry[1].value && (!entry[1].expired) || item.expired >= now) {
|
||||
cacheKeys.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(cacheKeys.keys());
|
||||
}
|
||||
|
||||
_update(key, item) {
|
||||
this.cache.set(key, item);
|
||||
this.size++;
|
||||
if (this.size >= this.max) {
|
||||
this.size = 0;
|
||||
this._cache = this.cache;
|
||||
this.cache = new Map();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = LRU;
|
||||
|
||||
72
node_modules/ylru/package.json
generated
vendored
Normal file
72
node_modules/ylru/package.json
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"ylru@1.2.1",
|
||||
"J:\\Github\\CURD-TS"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "ylru@1.2.1",
|
||||
"_id": "ylru@1.2.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-9Xa2M0FUeYnB3nuiiHYJI7J/6E8=",
|
||||
"_location": "/ylru",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "ylru@1.2.1",
|
||||
"name": "ylru",
|
||||
"escapedName": "ylru",
|
||||
"rawSpec": "1.2.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.2.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cache-content-type"
|
||||
],
|
||||
"_resolved": "http://192.168.250.101:4873/ylru/-/ylru-1.2.1.tgz",
|
||||
"_spec": "1.2.1",
|
||||
"_where": "J:\\Github\\CURD-TS",
|
||||
"author": {
|
||||
"name": "fengmk2"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/node-modules/ylru/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Extends LRU base on hashlru",
|
||||
"devDependencies": {
|
||||
"beautify-benchmark": "^0.2.4",
|
||||
"benchmark": "^2.1.3",
|
||||
"egg-bin": "^1.10.0",
|
||||
"eslint": "^3.12.2",
|
||||
"eslint-config-egg": "^3.2.0",
|
||||
"hashlru": "^1.0.3",
|
||||
"ko-sleep": "^1.0.2",
|
||||
"lru-cache": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4.0.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/node-modules/ylru",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "ylru",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/node-modules/ylru.git"
|
||||
},
|
||||
"scripts": {
|
||||
"autod": "autod",
|
||||
"ci": "npm run lint && npm run cov",
|
||||
"cov": "egg-bin cov",
|
||||
"lint": "eslint test *.js",
|
||||
"test": "npm run lint -- --fix && npm run test-local",
|
||||
"test-local": "egg-bin test"
|
||||
},
|
||||
"version": "1.2.1"
|
||||
}
|
||||
Reference in New Issue
Block a user