@mulingai-npm/redis 3.40.31 → 3.40.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/enums/redis-database.d.ts +1 -1
- package/dist/enums/redis-database.js +1 -1
- package/dist/managers/aggregated-content-manager.d.ts +5 -4
- package/dist/managers/aggregated-content-manager.js +13 -12
- package/dist/managers/page-content-manager.d.ts +5 -4
- package/dist/managers/page-content-manager.js +13 -12
- package/dist/managers/pricing-content-manager.d.ts +5 -5
- package/dist/managers/pricing-content-manager.js +13 -13
- package/package.json +1 -1
|
@@ -9,5 +9,5 @@ var RedisDatabase;
|
|
|
9
9
|
RedisDatabase[RedisDatabase["CONTENT_DATA"] = 3] = "CONTENT_DATA";
|
|
10
10
|
RedisDatabase[RedisDatabase["ACCOUNT_DATA"] = 4] = "ACCOUNT_DATA";
|
|
11
11
|
RedisDatabase[RedisDatabase["USAGE_DATA"] = 5] = "USAGE_DATA";
|
|
12
|
-
RedisDatabase[RedisDatabase["
|
|
12
|
+
RedisDatabase[RedisDatabase["SMART_TRANSLATION"] = 6] = "SMART_TRANSLATION";
|
|
13
13
|
})(RedisDatabase = exports.RedisDatabase || (exports.RedisDatabase = {}));
|
|
@@ -2,6 +2,7 @@ import { RedisClient } from '../redis-client';
|
|
|
2
2
|
export interface CachedAggregatedContent {
|
|
3
3
|
id: string;
|
|
4
4
|
locale: string;
|
|
5
|
+
domain: string;
|
|
5
6
|
payload: string;
|
|
6
7
|
createdAt: number;
|
|
7
8
|
lastUsedAt: number | null;
|
|
@@ -14,10 +15,10 @@ export declare class AggregatedContentManager {
|
|
|
14
15
|
private key;
|
|
15
16
|
private build;
|
|
16
17
|
private scan;
|
|
17
|
-
addAggregatedContent(locale: string, payload: unknown, ttl?: number): Promise<void>;
|
|
18
|
-
getAggregatedContent(locale: string): Promise<CachedAggregatedContent | null>;
|
|
18
|
+
addAggregatedContent(locale: string, domain: string, payload: unknown, ttl?: number): Promise<void>;
|
|
19
|
+
getAggregatedContent(locale: string, domain: string): Promise<CachedAggregatedContent | null>;
|
|
19
20
|
getAllAggregatedContents(): Promise<CachedAggregatedContent[]>;
|
|
20
|
-
clearAggregatedContent(locale: string): Promise<void>;
|
|
21
|
+
clearAggregatedContent(locale: string, domain: string): Promise<void>;
|
|
21
22
|
clearAllAggregatedContents(): Promise<void>;
|
|
22
|
-
incrementUsage(locale: string): Promise<void>;
|
|
23
|
+
incrementUsage(locale: string, domain: string): Promise<void>;
|
|
23
24
|
}
|
|
@@ -5,15 +5,16 @@ class AggregatedContentManager {
|
|
|
5
5
|
constructor(redis) {
|
|
6
6
|
this.redis = redis;
|
|
7
7
|
}
|
|
8
|
-
key(locale) {
|
|
9
|
-
return `aggregated-content--[${locale.toLowerCase()}]`;
|
|
8
|
+
key(locale, domain) {
|
|
9
|
+
return `aggregated-content--[${locale.toLowerCase()}]-[${domain.toLowerCase()}]`;
|
|
10
10
|
}
|
|
11
|
-
build(locale, payload) {
|
|
12
|
-
const id = this.key(locale);
|
|
11
|
+
build(locale, domain, payload) {
|
|
12
|
+
const id = this.key(locale, domain);
|
|
13
13
|
const now = Date.now();
|
|
14
14
|
return {
|
|
15
15
|
id,
|
|
16
16
|
locale,
|
|
17
|
+
domain,
|
|
17
18
|
payload: JSON.stringify(payload),
|
|
18
19
|
createdAt: now,
|
|
19
20
|
lastUsedAt: null,
|
|
@@ -30,13 +31,13 @@ class AggregatedContentManager {
|
|
|
30
31
|
} while (cursor !== 0);
|
|
31
32
|
return keys;
|
|
32
33
|
}
|
|
33
|
-
async addAggregatedContent(locale, payload, ttl = AggregatedContentManager.DEFAULT_TTL) {
|
|
34
|
-
const obj = this.build(locale, payload);
|
|
34
|
+
async addAggregatedContent(locale, domain, payload, ttl = AggregatedContentManager.DEFAULT_TTL) {
|
|
35
|
+
const obj = this.build(locale, domain, payload);
|
|
35
36
|
await this.redis.set(obj.id, JSON.stringify(obj));
|
|
36
37
|
await this.redis.expire(obj.id, ttl);
|
|
37
38
|
}
|
|
38
|
-
async getAggregatedContent(locale) {
|
|
39
|
-
const raw = await this.redis.get(this.key(locale));
|
|
39
|
+
async getAggregatedContent(locale, domain) {
|
|
40
|
+
const raw = await this.redis.get(this.key(locale, domain));
|
|
40
41
|
return raw ? JSON.parse(raw) : null;
|
|
41
42
|
}
|
|
42
43
|
async getAllAggregatedContents() {
|
|
@@ -48,17 +49,17 @@ class AggregatedContentManager {
|
|
|
48
49
|
const res = await p.exec();
|
|
49
50
|
return res.flatMap(([_, v]) => (v ? [JSON.parse(v)] : []));
|
|
50
51
|
}
|
|
51
|
-
async clearAggregatedContent(locale) {
|
|
52
|
-
await this.redis.unlink(this.key(locale));
|
|
52
|
+
async clearAggregatedContent(locale, domain) {
|
|
53
|
+
await this.redis.unlink(this.key(locale, domain));
|
|
53
54
|
}
|
|
54
55
|
async clearAllAggregatedContents() {
|
|
55
56
|
const keys = await this.scan('aggregated-content--[*');
|
|
56
57
|
if (keys.length)
|
|
57
58
|
await this.redis.unlink(...keys);
|
|
58
59
|
}
|
|
59
|
-
async incrementUsage(locale) {
|
|
60
|
+
async incrementUsage(locale, domain) {
|
|
60
61
|
var _a;
|
|
61
|
-
const k = this.key(locale);
|
|
62
|
+
const k = this.key(locale, domain);
|
|
62
63
|
const pipe = this.redis.pipeline();
|
|
63
64
|
pipe.get(k);
|
|
64
65
|
pipe.ttl(k);
|
|
@@ -4,6 +4,7 @@ export interface CachedPageContent {
|
|
|
4
4
|
path: string;
|
|
5
5
|
locale: string;
|
|
6
6
|
route: string;
|
|
7
|
+
domain: string;
|
|
7
8
|
payload: string;
|
|
8
9
|
createdAt: number;
|
|
9
10
|
lastUsedAt: number | null;
|
|
@@ -16,12 +17,12 @@ export declare class PageContentManager {
|
|
|
16
17
|
private key;
|
|
17
18
|
private build;
|
|
18
19
|
private scan;
|
|
19
|
-
addPageContent(locale: string, route: string, payload: unknown, ttl?: number): Promise<void>;
|
|
20
|
-
getPageContent(locale: string, route: string): Promise<CachedPageContent | null>;
|
|
20
|
+
addPageContent(locale: string, route: string, domain: string, payload: unknown, ttl?: number): Promise<void>;
|
|
21
|
+
getPageContent(locale: string, route: string, domain: string): Promise<CachedPageContent | null>;
|
|
21
22
|
getAllPageContents(): Promise<CachedPageContent[]>;
|
|
22
23
|
getAllPageContentsByLocale(locale: string): Promise<CachedPageContent[]>;
|
|
23
|
-
clearPageContent(locale: string, route: string): Promise<void>;
|
|
24
|
+
clearPageContent(locale: string, route: string, domain: string): Promise<void>;
|
|
24
25
|
clearAllPageContents(): Promise<void>;
|
|
25
26
|
clearAllPageContentsByLocale(locale: string): Promise<void>;
|
|
26
|
-
incrementUsage(locale: string, route: string): Promise<void>;
|
|
27
|
+
incrementUsage(locale: string, route: string, domain: string): Promise<void>;
|
|
27
28
|
}
|
|
@@ -5,17 +5,18 @@ class PageContentManager {
|
|
|
5
5
|
constructor(redis) {
|
|
6
6
|
this.redis = redis;
|
|
7
7
|
}
|
|
8
|
-
key(locale, route) {
|
|
9
|
-
return `page-content--[${locale.toLowerCase()}]-[${route.toLowerCase()}]`;
|
|
8
|
+
key(locale, route, domain) {
|
|
9
|
+
return `page-content--[${locale.toLowerCase()}]-[${route.toLowerCase()}]-[${domain.toLowerCase()}]`;
|
|
10
10
|
}
|
|
11
|
-
build(locale, route, payload) {
|
|
12
|
-
const id = this.key(locale, route);
|
|
11
|
+
build(locale, route, domain, payload) {
|
|
12
|
+
const id = this.key(locale, route, domain);
|
|
13
13
|
const now = Date.now();
|
|
14
14
|
return {
|
|
15
15
|
id,
|
|
16
16
|
path: `/${locale}/${route}`,
|
|
17
17
|
locale,
|
|
18
18
|
route,
|
|
19
|
+
domain,
|
|
19
20
|
payload: JSON.stringify(payload),
|
|
20
21
|
createdAt: now,
|
|
21
22
|
lastUsedAt: null,
|
|
@@ -32,13 +33,13 @@ class PageContentManager {
|
|
|
32
33
|
} while (cursor !== 0);
|
|
33
34
|
return keys;
|
|
34
35
|
}
|
|
35
|
-
async addPageContent(locale, route, payload, ttl = PageContentManager.DEFAULT_TTL) {
|
|
36
|
-
const obj = this.build(locale, route, payload);
|
|
36
|
+
async addPageContent(locale, route, domain, payload, ttl = PageContentManager.DEFAULT_TTL) {
|
|
37
|
+
const obj = this.build(locale, route, domain, payload);
|
|
37
38
|
await this.redis.set(obj.id, JSON.stringify(obj));
|
|
38
39
|
await this.redis.expire(obj.id, ttl);
|
|
39
40
|
}
|
|
40
|
-
async getPageContent(locale, route) {
|
|
41
|
-
const raw = await this.redis.get(this.key(locale, route));
|
|
41
|
+
async getPageContent(locale, route, domain) {
|
|
42
|
+
const raw = await this.redis.get(this.key(locale, route, domain));
|
|
42
43
|
return raw ? JSON.parse(raw) : null;
|
|
43
44
|
}
|
|
44
45
|
async getAllPageContents() {
|
|
@@ -59,8 +60,8 @@ class PageContentManager {
|
|
|
59
60
|
const res = await p.exec();
|
|
60
61
|
return res.flatMap(([_, v]) => (v ? [JSON.parse(v)] : []));
|
|
61
62
|
}
|
|
62
|
-
async clearPageContent(locale, route) {
|
|
63
|
-
await this.redis.unlink(this.key(locale, route));
|
|
63
|
+
async clearPageContent(locale, route, domain) {
|
|
64
|
+
await this.redis.unlink(this.key(locale, route, domain));
|
|
64
65
|
}
|
|
65
66
|
async clearAllPageContents() {
|
|
66
67
|
const keys = await this.scan('page-content--[*');
|
|
@@ -72,9 +73,9 @@ class PageContentManager {
|
|
|
72
73
|
if (keys.length)
|
|
73
74
|
await this.redis.unlink(...keys);
|
|
74
75
|
}
|
|
75
|
-
async incrementUsage(locale, route) {
|
|
76
|
+
async incrementUsage(locale, route, domain) {
|
|
76
77
|
var _a;
|
|
77
|
-
const k = this.key(locale, route);
|
|
78
|
+
const k = this.key(locale, route, domain);
|
|
78
79
|
const pipe = this.redis.pipeline();
|
|
79
80
|
pipe.get(k);
|
|
80
81
|
pipe.ttl(k);
|
|
@@ -2,7 +2,7 @@ import { RedisClient } from '../redis-client';
|
|
|
2
2
|
export interface CachedPricingContent {
|
|
3
3
|
id: string;
|
|
4
4
|
locale: string;
|
|
5
|
-
|
|
5
|
+
domain: string;
|
|
6
6
|
country: string;
|
|
7
7
|
currency: string;
|
|
8
8
|
sku?: string;
|
|
@@ -18,8 +18,8 @@ export declare class PricingContentManager {
|
|
|
18
18
|
private key;
|
|
19
19
|
private build;
|
|
20
20
|
private scan;
|
|
21
|
-
addPricingContent(locale: string,
|
|
22
|
-
getPricingContent(locale: string,
|
|
23
|
-
clearPricingContent(locale: string,
|
|
24
|
-
incrementUsage(locale: string,
|
|
21
|
+
addPricingContent(locale: string, domain: string, country: string, currency: string, sku: string | undefined, payload: unknown, ttl?: number): Promise<void>;
|
|
22
|
+
getPricingContent(locale: string, domain: string, country: string, currency: string, sku: string | undefined): Promise<CachedPricingContent | null>;
|
|
23
|
+
clearPricingContent(locale: string, domain: string, country: string, currency: string, sku: string | undefined): Promise<void>;
|
|
24
|
+
incrementUsage(locale: string, domain: string, country: string, currency: string, sku: string | undefined): Promise<void>;
|
|
25
25
|
}
|
|
@@ -5,20 +5,20 @@ class PricingContentManager {
|
|
|
5
5
|
constructor(redis) {
|
|
6
6
|
this.redis = redis;
|
|
7
7
|
}
|
|
8
|
-
key(locale,
|
|
9
|
-
const parts = [locale.toLowerCase(),
|
|
8
|
+
key(locale, domain, country, currency, sku) {
|
|
9
|
+
const parts = [locale.toLowerCase(), domain.toLowerCase(), country.toUpperCase(), currency.toUpperCase()];
|
|
10
10
|
if (sku) {
|
|
11
11
|
parts.push(sku.toLowerCase());
|
|
12
12
|
}
|
|
13
13
|
return `pricing--[${parts.join(']-[')}]`;
|
|
14
14
|
}
|
|
15
|
-
build(locale,
|
|
16
|
-
const id = this.key(locale,
|
|
15
|
+
build(locale, domain, country, currency, sku, payload) {
|
|
16
|
+
const id = this.key(locale, domain, country, currency, sku);
|
|
17
17
|
const now = Date.now();
|
|
18
18
|
return {
|
|
19
19
|
id,
|
|
20
20
|
locale,
|
|
21
|
-
|
|
21
|
+
domain,
|
|
22
22
|
country,
|
|
23
23
|
currency,
|
|
24
24
|
sku,
|
|
@@ -38,21 +38,21 @@ class PricingContentManager {
|
|
|
38
38
|
} while (cursor !== 0);
|
|
39
39
|
return keys;
|
|
40
40
|
}
|
|
41
|
-
async addPricingContent(locale,
|
|
42
|
-
const obj = this.build(locale,
|
|
41
|
+
async addPricingContent(locale, domain, country, currency, sku, payload, ttl = PricingContentManager.DEFAULT_TTL) {
|
|
42
|
+
const obj = this.build(locale, domain, country, currency, sku, payload);
|
|
43
43
|
await this.redis.set(obj.id, JSON.stringify(obj));
|
|
44
44
|
await this.redis.expire(obj.id, ttl);
|
|
45
45
|
}
|
|
46
|
-
async getPricingContent(locale,
|
|
47
|
-
const raw = await this.redis.get(this.key(locale,
|
|
46
|
+
async getPricingContent(locale, domain, country, currency, sku) {
|
|
47
|
+
const raw = await this.redis.get(this.key(locale, domain, country, currency, sku));
|
|
48
48
|
return raw ? JSON.parse(raw) : null;
|
|
49
49
|
}
|
|
50
|
-
async clearPricingContent(locale,
|
|
51
|
-
await this.redis.unlink(this.key(locale,
|
|
50
|
+
async clearPricingContent(locale, domain, country, currency, sku) {
|
|
51
|
+
await this.redis.unlink(this.key(locale, domain, country, currency, sku));
|
|
52
52
|
}
|
|
53
|
-
async incrementUsage(locale,
|
|
53
|
+
async incrementUsage(locale, domain, country, currency, sku) {
|
|
54
54
|
var _a;
|
|
55
|
-
const k = this.key(locale,
|
|
55
|
+
const k = this.key(locale, domain, country, currency, sku);
|
|
56
56
|
const pipe = this.redis.pipeline();
|
|
57
57
|
pipe.get(k);
|
|
58
58
|
pipe.ttl(k);
|