New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nocobase/cache

Package Overview
Dependencies
Maintainers
0
Versions
445
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nocobase/cache - npm Package Compare versions

Comparing version 1.6.0-beta.3 to 1.6.0-beta.4

lib/counter/index.d.ts

3

lib/bloom-filter/redis-bloom-filter.d.ts

@@ -9,3 +9,2 @@ /**

*/
import { RedisStore } from 'cache-manager-redis-yet';
import { BloomFilter } from '.';

@@ -19,3 +18,3 @@ import { Cache } from '../cache';

constructor(cache: Cache);
getStore(): RedisStore<import("redis").RedisClientType>;
private get store();
reserve(key: string, errorRate: number, capacity: number): Promise<void>;

@@ -22,0 +21,0 @@ add(key: string, value: string): Promise<void>;

@@ -39,20 +39,23 @@ /**

}
getStore() {
get store() {
return this.cache.store.store;
}
async reserve(key, errorRate, capacity) {
const store = this.getStore();
await store.client.bf.reserve(key, errorRate, capacity);
try {
await this.store.client.bf.reserve(key, errorRate, capacity);
} catch (error) {
if (error.message.includes("ERR item exists")) {
return;
}
throw error;
}
}
async add(key, value) {
const store = this.getStore();
await store.client.bf.add(key, value);
await this.store.client.bf.add(key, value);
}
async mAdd(key, values) {
const store = this.getStore();
await store.client.bf.mAdd(key, values);
await this.store.client.bf.mAdd(key, values);
}
async exists(key, value) {
const store = this.getStore();
return await store.client.bf.exists(key, value);
return this.store.client.bf.exists(key, value);
}

@@ -59,0 +62,0 @@ };

@@ -12,2 +12,4 @@ /**

import { BloomFilter } from './bloom-filter';
import { Counter } from './counter';
import { LockManager } from '@nocobase/lock-manager';
type StoreOptions = {

@@ -23,5 +25,7 @@ store?: 'memory' | FactoryStore<Store, any>;

};
prefix: string;
}>;
export declare class CacheManager {
defaultStore: string;
prefix?: string;
private stores;

@@ -57,3 +61,11 @@ /**

}): Promise<BloomFilter>;
/**
* @experimental
*/
createCounter(options: {
name: string;
prefix?: string;
store?: string;
}, lockManager?: LockManager): Promise<Counter>;
}
export {};

@@ -50,4 +50,6 @@ /**

var import_redis_bloom_filter = require("./bloom-filter/redis-bloom-filter");
var import_counter = require("./counter");
const _CacheManager = class _CacheManager {
defaultStore;
prefix;
stores = /* @__PURE__ */ new Map();

@@ -84,4 +86,5 @@ /**

const cacheOptions = (0, import_deepmerge.default)(defaultOptions, options || {});
const { defaultStore = "memory", stores } = cacheOptions;
const { defaultStore = "memory", stores, prefix } = cacheOptions;
this.defaultStore = defaultStore;
this.prefix = prefix;
for (const [name, store] of Object.entries(stores)) {

@@ -114,3 +117,5 @@ const { store: s, ...globalConfig } = store;

async createCache(options) {
const { name, prefix, store = this.defaultStore, ...config } = options;
const { name, store = this.defaultStore, ...config } = options;
let { prefix } = options;
prefix = this.prefix ? prefix ? `${this.prefix}:${prefix}` : this.prefix : prefix;
if (!import_lodash.default.isEmpty(config) || store === "memory") {

@@ -170,2 +175,27 @@ const newStore = await this.createStore({ name, storeType: store, ...config });

}
/**
* @experimental
*/
async createCounter(options, lockManager) {
const { store = this.defaultStore, name, prefix } = options || {};
let cache;
if (store !== "memory") {
try {
cache = this.getCache(name);
} catch (error) {
cache = await this.createCache({ name, store, prefix });
}
}
switch (store) {
case "memory":
return new import_counter.MemoryCounter();
case "redis":
return new import_counter.RedisCounter(cache);
default:
if (!lockManager) {
throw new Error(`Counter store [${store}] is not supported`);
}
return new import_counter.LockCounter(cache, lockManager);
}
}
};

@@ -172,0 +202,0 @@ __name(_CacheManager, "CacheManager");

@@ -12,1 +12,2 @@ /**

export * from './bloom-filter';
export * from './counter';

@@ -29,2 +29,3 @@ /**

__reExport(src_exports, require("./bloom-filter"), module.exports);
__reExport(src_exports, require("./counter"), module.exports);
// Annotate the CommonJS export names for ESM import in node:

@@ -34,3 +35,4 @@ 0 && (module.exports = {

...require("./cache"),
...require("./bloom-filter")
...require("./bloom-filter"),
...require("./counter")
});
{
"name": "@nocobase/cache",
"version": "1.6.0-beta.3",
"version": "1.6.0-beta.4",
"description": "",

@@ -9,2 +9,3 @@ "license": "AGPL-3.0",

"dependencies": {
"@nocobase/lock-manager": "1.6.0-alpha.6",
"bloom-filters": "^3.0.1",

@@ -22,3 +23,3 @@ "cache-manager": "^5.2.4",

},
"gitHead": "19a659c49d7eedd3d57e46f9df2e8540f55c99b7"
"gitHead": "4419f433716dadf34886b261d9abe20e74551044"
}
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