Comparing version 1.2.1 to 1.3.0
@@ -0,1 +1,8 @@ | ||
# [1.3.0](https://github.com/TinkoffCreditSystems/cachalot/compare/v1.2.1...v1.3.0) (2020-01-27) | ||
### Features | ||
* Multiple get and set are now using for read/write tags. ([71d60a3](https://github.com/TinkoffCreditSystems/cachalot/commit/71d60a3)) | ||
## [1.2.1](https://github.com/TinkoffCreditSystems/cachalot/compare/v1.2.0...v1.2.1) (2020-01-23) | ||
@@ -2,0 +9,0 @@ |
@@ -48,2 +48,6 @@ import { ConnectionStatus } from '../../connection-status'; | ||
/** | ||
* Set multiple values to redis storage | ||
*/ | ||
mset(values: Map<string, any>): Promise<void>; | ||
/** | ||
* The get command method provided by the adapter. Use get command to get key value from redis | ||
@@ -53,2 +57,7 @@ */ | ||
/** | ||
* The mget command method provided by the adapter. | ||
* Use mget command to get multiple values from redis | ||
*/ | ||
mget(keys: string[]): Promise<(string | null)[]>; | ||
/** | ||
* The del method provided by the adapter. Uses the del command to remove the key. | ||
@@ -55,0 +64,0 @@ */ |
@@ -57,2 +57,8 @@ "use strict"; | ||
/** | ||
* Set multiple values to redis storage | ||
*/ | ||
async mset(values) { | ||
await with_timeout_1.withTimeout(this.redisInstance.mset(values), this.options.operationTimeout); | ||
} | ||
/** | ||
* The get command method provided by the adapter. Use get command to get key value from redis | ||
@@ -64,2 +70,10 @@ */ | ||
/** | ||
* The mget command method provided by the adapter. | ||
* Use mget command to get multiple values from redis | ||
*/ | ||
async mget(keys) { | ||
const cacheKeys = keys.map(key => `${exports.CACHE_PREFIX}:${key}`); | ||
return with_timeout_1.withTimeout(this.redisInstance.mget(...cacheKeys), this.options.operationTimeout); | ||
} | ||
/** | ||
* The del method provided by the adapter. Uses the del command to remove the key. | ||
@@ -66,0 +80,0 @@ */ |
@@ -18,3 +18,5 @@ import { ConnectionStatus } from '../../connection-status'; | ||
isLockExists(key: string): Promise<boolean>; | ||
mset(values: Map<string, any>): Promise<void>; | ||
mget(keys: string[]): Promise<(string | null)[]>; | ||
} | ||
export default TestStorageAdapter; |
@@ -51,4 +51,14 @@ "use strict"; | ||
} | ||
async mset(values) { | ||
this.checkConnection(); | ||
values.forEach((value, key) => { | ||
this.testInterface.internalStorage[key] = value; | ||
}); | ||
} | ||
async mget(keys) { | ||
this.checkConnection(); | ||
return keys.map(key => { var _a; return _a = this.testInterface.internalStorage[key], (_a !== null && _a !== void 0 ? _a : null); }); | ||
} | ||
} | ||
exports.default = TestStorageAdapter; | ||
//# sourceMappingURL=index.js.map |
@@ -11,5 +11,2 @@ "use strict"; | ||
class RefreshAheadManager extends base_1.BaseManager { | ||
static getName() { | ||
return 'refresh-ahead'; | ||
} | ||
constructor(options) { | ||
@@ -30,2 +27,5 @@ super({ | ||
} | ||
static getName() { | ||
return 'refresh-ahead'; | ||
} | ||
async get(key, executor, options = {}) { | ||
@@ -32,0 +32,0 @@ const executorContext = { key, executor, options }; |
@@ -33,7 +33,16 @@ import { ConnectionStatus } from './connection-status'; | ||
/** | ||
* get - возвращает значение для ключа key | ||
* Если запись отсутствует, возвращает null | ||
* mset - stores values to the storage | ||
*/ | ||
mset(values: Map<string, any>): Promise<void>; | ||
/** | ||
* get - returns value by key | ||
* Returns null if record does not exist | ||
*/ | ||
get(key: string): Promise<string | null>; | ||
/** | ||
* mget - returns values by keys | ||
* Returns null for records that do not exist | ||
*/ | ||
mget(keys: string[]): Promise<(string | null)[]>; | ||
/** | ||
* Removes the entry with the key key from storage | ||
@@ -40,0 +49,0 @@ */ |
@@ -1,4 +0,4 @@ | ||
import { WriteOptions, Storage, StorageRecord, StorageRecordTag, StorageRecordValue } from '../storage'; | ||
import { ConnectionStatus } from '../connection-status'; | ||
import { Storage, StorageRecord, StorageRecordTag, StorageRecordValue, WriteOptions } from '../storage'; | ||
import { StorageAdapter } from '../storage-adapter'; | ||
import { ConnectionStatus } from '../connection-status'; | ||
export declare const TAGS_VERSIONS_ALIAS = "cache-tags-versions"; | ||
@@ -5,0 +5,0 @@ export declare type BaseStorageOptions = { |
@@ -9,7 +9,7 @@ "use strict"; | ||
const uniq_1 = __importDefault(require("lodash/uniq")); | ||
const serialize_1 = __importDefault(require("../serialize")); | ||
const connection_status_1 = require("../connection-status"); | ||
const deserialize_1 = __importDefault(require("../deserialize")); | ||
const record_1 = __importDefault(require("../record")); | ||
const create_tag_1 = __importDefault(require("../record/create-tag")); | ||
const connection_status_1 = require("../connection-status"); | ||
const serialize_1 = __importDefault(require("../serialize")); | ||
exports.TAGS_VERSIONS_ALIAS = 'cache-tags-versions'; | ||
@@ -51,3 +51,4 @@ /** | ||
async setTagVersions(tags) { | ||
return Promise.all(tags.map(async (tag) => this.adapter.set(this.createTagKey(tag.name), `${tag.version}`))); | ||
const values = new Map(tags.map(tag => [this.createTagKey(tag.name), `${tag.version}`])); | ||
return this.adapter.mset(values); | ||
} | ||
@@ -89,6 +90,7 @@ /** | ||
async getTags(tagNames) { | ||
return Promise.all(tagNames.map(async (tagName) => ({ | ||
const existingTags = await this.adapter.mget(tagNames.map(tagName => this.createTagKey(tagName))); | ||
return tagNames.map((tagName, index) => ({ | ||
name: tagName, | ||
version: Number(await this.adapter.get(this.createTagKey(tagName))) || 0 | ||
}))); | ||
version: Number(existingTags[index]) || 0 | ||
})); | ||
} | ||
@@ -95,0 +97,0 @@ /** |
{ | ||
"name": "cachalot", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Cache manager for nodejs with support different cache strategies", | ||
@@ -44,13 +44,13 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/ioredis": "^4.0.12", | ||
"@semantic-release/changelog": "^3.0.4", | ||
"@semantic-release/git": "^7.0.16", | ||
"@types/ioredis": "^4.14.4", | ||
"@types/jest": "^24.0.15", | ||
"@types/lodash": "^4.14.135", | ||
"@types/lodash": "^4.14.149", | ||
"@types/node": "^8", | ||
"coveralls": "^3.0.4", | ||
"cz-conventional-changelog": "^3.0.2", | ||
"ioredis": "^4.11.1", | ||
"ioredis": "^4.14.1", | ||
"jest": "^24.8.0", | ||
"semantic-release": "^15.13.24", | ||
"@semantic-release/changelog": "^3.0.4", | ||
"@semantic-release/git": "^7.0.16", | ||
"ts-jest": "^24.0.2", | ||
@@ -60,3 +60,3 @@ "tslint": "^5.18.0", | ||
"typedoc": "^0.15.0", | ||
"typescript": "^3.5.2" | ||
"typescript": "^3.7.5" | ||
}, | ||
@@ -63,0 +63,0 @@ "config": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
117204
1641