Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alaska-cache-lru

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alaska-cache-lru - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

71

index.js

@@ -1,28 +0,30 @@

/**
* @copyright Maichong Software Ltd. 2016 http://maichong.it
* @date 2016-02-28
* @author Liang <liang@maichong.it>
*/
// @flow
'use strict';
/* eslint new-cap:0 */
const LRU = require('lru-cache');
const _ = require('lodash');
const debug = require('debug')('alaska-cache-lru');
import LRU from 'lru-cache';
import Debugger from 'debug';
import { Driver } from 'alaska';
class LruCacheDriver {
constructor(options) {
const debug = Debugger('alaska-cache-lru');
export default class LruCacheDriver extends Driver {
static classOfCacheDriver = true;
instanceOfCacheDriver: true;
_maxAge: number;
_driver: any;
constructor(service: Alaska$Service, options: Object) {
super(service, options);
this.instanceOfCacheDriver = true;
this._maxAge = options.maxAge || 0;
this._driver = LRU(options);
this.type = 'lru';
//标识已经是缓存对象实例
this.isCacheDriver = true;
//标识本驱动不会序列化数据
this.noSerialization = true;
this._driver = new LRU(options);
}
/**
* @returns {LRUCache}
* 获取底层驱动
* @returns {any}
*/
driver() {
driver(): any {
return this._driver;

@@ -38,3 +40,3 @@ }

*/
set(key, value, lifetime) {
set(key: string, value: any, lifetime?: number): Promise<any> {
debug('set', key, '=>', value, '(', lifetime !== undefined ? lifetime : '{' + this._maxAge + '}', ')');

@@ -49,3 +51,3 @@ return Promise.resolve(this._driver.set(key, value, lifetime));

*/
get(key) {
get(key: string): Promise<any> {
let value = this._driver.get(key);

@@ -60,3 +62,3 @@ debug('get', key, '=>', value);

*/
del(key) {
del(key: string): Promise<any> {
debug('del', key);

@@ -71,3 +73,3 @@ return Promise.resolve(this._driver.del(key));

*/
has(key) {
has(key: string): Promise<boolean> {
let exists = this._driver.has(key);

@@ -83,3 +85,3 @@ debug('has', key, '=>', exists);

*/
inc(key) {
inc(key: string): Promise<number> {
let value = this._driver.get(key);

@@ -89,3 +91,3 @@ if (!value) {

}
value++;
value += 1;
this._driver.set(key, value);

@@ -101,3 +103,3 @@ debug('inc', key, '=>', value);

*/
dec(key) {
dec(key: string): Promise<number> {
let value = this._driver.get(key);

@@ -107,3 +109,3 @@ if (!value) {

}
value--;
value -= 1;
this._driver.set(key, value);

@@ -118,3 +120,3 @@ debug('inc', key, '=>', value);

*/
size() {
size(): Promise<number> {
debug('size', this._driver.itemCount);

@@ -127,3 +129,3 @@ return Promise.resolve(this._driver.itemCount);

*/
prune() {
prune(): Promise<void> {
debug('prune');

@@ -137,3 +139,3 @@ this._driver.prune();

*/
flush() {
flush(): Promise<void> {
debug('flush');

@@ -143,6 +145,7 @@ this._driver.reset();

}
onDestroy() {
this._driver.reset();
this._driver = null;
}
}
LruCacheDriver.default = LruCacheDriver;
module.exports = LruCacheDriver;
{
"name": "alaska-cache-lru",
"version": "0.10.0",
"version": "0.11.0",
"description": "Alaska LRU cache driver",

@@ -9,22 +9,10 @@ "keywords": [

],
"main": "lib/lru.js",
"scripts": {},
"repository": {
"type": "git",
"url": "git+https://github.com/maichong/alaska-cache-lru.git"
},
"author": {
"email": "liang@maichong.it",
"name": "liang",
"url": "https://github.com/liangxingchen"
},
"main": "index.js",
"repository": "https://github.com/maichong/alaska/tree/master/packages/alaska-cache-lru",
"author": "Liang <liang@maichong.it> (https://github.com/liangxingchen)",
"license": "MIT",
"bugs": {
"url": "https://github.com/maichong/alaska-cache-lru/issues"
},
"homepage": "https://github.com/maichong/alaska-cache-lru#readme",
"dependencies": {
"debug": "^2.2.0",
"lru-cache": "^4.0.0"
"debug": "^2.6.3",
"lru-cache": "^4.0.2"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc