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.11.21 to 0.12.0

73

index.js

@@ -1,23 +0,30 @@

// @flow
'use strict';
/* eslint new-cap:0 */
Object.defineProperty(exports, "__esModule", {
value: true
});
import LRU from 'lru-cache';
import Debugger from 'debug';
import { Driver } from 'alaska';
var _lruCache = require('lru-cache');
const debug = Debugger('alaska-cache-lru');
var _lruCache2 = _interopRequireDefault(_lruCache);
export default class LruCacheDriver extends Driver {
static classOfCacheDriver = true;
var _debug = require('debug');
instanceOfCacheDriver: true;
_maxAge: number;
_driver: any;
var _debug2 = _interopRequireDefault(_debug);
constructor(service: Alaska$Service, options: Object) {
var _alaska = require('alaska');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const debug = (0, _debug2.default)('alaska-cache-lru');
/* eslint new-cap:0 */
class LruCacheDriver extends _alaska.Driver {
constructor(service, options) {
super(service, options);
this.instanceOfCacheDriver = true;
this._maxAge = options.maxAge || 0;
this._driver = new LRU(options);
this._driver = new _lruCache2.default(options);
}

@@ -29,3 +36,3 @@

*/
driver(): any {
driver() {
return this._driver;

@@ -35,3 +42,3 @@ }

/**
* [async] 设置缓存
* 设置缓存
* @param {string} key

@@ -42,3 +49,3 @@ * @param {*} value

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

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

/**
* [async] 获取缓存
* 获取缓存
* @param key
* @returns {*}
*/
get(key: string): Promise<any> {
get(key) {
let value = this._driver.get(key);

@@ -61,6 +68,6 @@ debug('get', key, '=>', value);

/**
* [async] 删除缓存
* 删除缓存
* @param key
*/
del(key: string): Promise<any> {
del(key) {
debug('del', key);

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

/**
* [async] 判断缓存键是否存在
* 判断缓存键是否存在
* @param key
* @returns {boolean}
*/
has(key: string): Promise<boolean> {
has(key) {
let exists = this._driver.has(key);

@@ -83,7 +90,7 @@ debug('has', key, '=>', exists);

/**
* [async] 自增并返回结果
* 自增并返回结果
* @param key
* @returns {number}
*/
inc(key: string): Promise<number> {
inc(key) {
let value = this._driver.get(key);

@@ -100,7 +107,7 @@ if (!value) {

/**
* [async] 自减并返回结果
* 自减并返回结果
* @param key
* @returns {number}
*/
dec(key: string): Promise<number> {
dec(key) {
let value = this._driver.get(key);

@@ -117,6 +124,6 @@ if (!value) {

/**
* [async] 返回缓存数量
* 返回缓存数量
* @returns {number}
*/
size(): Promise<number> {
size() {
debug('size', this._driver.itemCount);

@@ -127,5 +134,5 @@ return Promise.resolve(this._driver.itemCount);

/**
* [async] 清理过期缓存
* 清理过期缓存
*/
prune(): Promise<void> {
prune() {
debug('prune');

@@ -137,5 +144,5 @@ this._driver.prune();

/**
* [async] 清空缓存
* 清空缓存
*/
flush(): Promise<void> {
flush() {
debug('flush');

@@ -151,1 +158,3 @@ this._driver.reset();

}
exports.default = LruCacheDriver;
LruCacheDriver.classOfCacheDriver = true;
{
"name": "alaska-cache-lru",
"version": "0.11.21",
"version": "0.12.0",
"description": "Alaska LRU cache driver",

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

],
"alaska": "driver",
"alaska-driver": "cache",
"main": "index.js",
"repository": "https://github.com/maichong/alaska/tree/master/packages/alaska-cache-lru",
"repository": "https://github.com/maichong/alaska/tree/master/src/alaska-cache-lru",
"author": "Liang <liang@maichong.it> (https://github.com/liangxingchen)",
"license": "MIT",
"dependencies": {
"debug": "^2.6.8",
"debug": "^3.1.0",
"lru-cache": "^4.1.1"
}
}
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