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

cachalot

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cachalot - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

# [1.4.0](https://github.com/TinkoffCreditSystems/cachalot/compare/v1.3.1...v1.4.0) (2020-01-29)
### Features
* Tags can be stored separately in case the main redis instance uses eviction policy. ([c25ae76](https://github.com/TinkoffCreditSystems/cachalot/commit/c25ae76))
## [1.3.1](https://github.com/TinkoffCreditSystems/cachalot/compare/v1.3.0...v1.3.1) (2020-01-28)

@@ -2,0 +9,0 @@

1

dist/cache.d.ts

@@ -11,2 +11,3 @@ import { Executor, ValueOfExecutor } from './executor';

adapter: StorageAdapter;
tagsAdapter?: StorageAdapter;
}

@@ -13,0 +14,0 @@ export interface ManagerConstructor<T extends BaseManager = any> {

@@ -38,2 +38,3 @@ "use strict";

adapter: options.adapter,
tagsAdapter: options.tagsAdapter,
prefix: options.prefix,

@@ -40,0 +41,0 @@ hashKeys: options.hashKeys

@@ -7,2 +7,3 @@ import { ConnectionStatus } from '../connection-status';

adapter: StorageAdapter;
tagsAdapter?: StorageAdapter;
prefix?: string;

@@ -53,2 +54,7 @@ hashKeys?: boolean;

/**
* Adapter for tags should be provided if your primary adapter uses eviction policy.
* This adapter should not use any eviction policy. Records should be deleted only by demand or expiration.
*/
private readonly tagsAdapter;
/**
* Gets a record using an adapter. It is expected that the adapter returns or null (value not found)

@@ -55,0 +61,0 @@ * or serialized StorageRecord.

6

dist/storages/base.js

@@ -23,2 +23,3 @@ "use strict";

constructor(options) {
var _a;
/**

@@ -29,2 +30,3 @@ * An offline commands queue.

this.adapter = options.adapter;
this.tagsAdapter = (_a = options.tagsAdapter, (_a !== null && _a !== void 0 ? _a : options.adapter));
this.prefix = options.prefix || '';

@@ -53,3 +55,3 @@ this.hashKeys = options.hashKeys || false;

const values = new Map(tags.map(tag => [this.createTagKey(tag.name), `${tag.version}`]));
return this.adapter.mset(values);
return this.tagsAdapter.mset(values);
}

@@ -91,3 +93,3 @@ /**

async getTags(tagNames) {
const existingTags = await this.adapter.mget(tagNames.map(tagName => this.createTagKey(tagName)));
const existingTags = await this.tagsAdapter.mget(tagNames.map(tagName => this.createTagKey(tagName)));
return tagNames.map((tagName, index) => ({

@@ -94,0 +96,0 @@ name: tagName,

{
"name": "cachalot",
"version": "1.3.1",
"version": "1.4.0",
"description": "Cache manager for nodejs with support different cache strategies",

@@ -5,0 +5,0 @@ "keywords": [

@@ -54,2 +54,21 @@ # Cachalot

```
If your Redis instance uses eviction policy you need to use separate Redis instance for tags. **Tags should not be evicted!**
```typescript
// cache-with-tags.ts
import Redis from 'ioredis';
import Cache, { RedisStorageAdapter } from 'cachalot';
import logger from './logger';
const redis = new Redis(); // with eviction policy enabled
const redisForTags = new Redis(6380);
export const cache = new Cache({
adapter: new RedisStorageAdapter(redis),
tagsAdapter: new RedisStorageAdapter(redisForTags),
logger,
});
```
There are three main methods of working with Cache; their behavior depends on the chosen caching strategy:

@@ -56,0 +75,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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