@pioneer-platform/pioneer-cache 1.22.0 → 1.22.1
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +8 -0
- package/dist/core/base-cache.d.ts +2 -1
- package/dist/core/base-cache.js +2 -1
- package/dist/core/cache-manager.d.ts +1 -0
- package/dist/core/cache-manager.js +1 -1
- package/dist/stores/balance-cache.d.ts +1 -1
- package/dist/stores/balance-cache.js +2 -2
- package/package.json +4 -4
- package/src/core/base-cache.ts +3 -1
- package/src/core/cache-manager.ts +2 -1
- package/src/stores/balance-cache.ts +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @pioneer-platform/pioneer-cache@1.
|
|
3
|
+
> @pioneer-platform/pioneer-cache@1.22.1 build /Users/highlander/WebstormProjects/keepkey-stack/projects/pioneer/modules/pioneer/pioneer-cache
|
|
4
4
|
> tsc
|
|
5
5
|
|
package/CHANGELOG.md
CHANGED
|
@@ -5,11 +5,12 @@ export declare abstract class BaseCache<T> {
|
|
|
5
5
|
protected config: CacheConfig;
|
|
6
6
|
protected queueInitialized: boolean;
|
|
7
7
|
protected TAG: string;
|
|
8
|
+
protected redisPublisher?: any;
|
|
8
9
|
private cachedStats;
|
|
9
10
|
private cachedStatsTimestamp;
|
|
10
11
|
private readonly STATS_CACHE_TTL;
|
|
11
12
|
private pendingFetches;
|
|
12
|
-
constructor(redis: any, config: CacheConfig);
|
|
13
|
+
constructor(redis: any, config: CacheConfig, redisPublisher?: any);
|
|
13
14
|
/**
|
|
14
15
|
* Initialize Redis queue for background refresh
|
|
15
16
|
*/
|
package/dist/core/base-cache.js
CHANGED
|
@@ -29,7 +29,7 @@ const MAJOR_CRYPTO_WHITELIST = new Set([
|
|
|
29
29
|
'bip122:000000000000000000651ef99cb9fcbe/slip44:145', // Bitcoin Cash
|
|
30
30
|
]);
|
|
31
31
|
class BaseCache {
|
|
32
|
-
constructor(redis, config) {
|
|
32
|
+
constructor(redis, config, redisPublisher) {
|
|
33
33
|
this.queueInitialized = false;
|
|
34
34
|
// Cache for stats (to avoid expensive SCAN operations on every health check)
|
|
35
35
|
this.cachedStats = null;
|
|
@@ -40,6 +40,7 @@ class BaseCache {
|
|
|
40
40
|
this.pendingFetches = new Map();
|
|
41
41
|
this.redis = redis;
|
|
42
42
|
this.config = config;
|
|
43
|
+
this.redisPublisher = redisPublisher;
|
|
43
44
|
this.TAG = ` | ${config.name}Cache | `;
|
|
44
45
|
// Initialize queue if enabled
|
|
45
46
|
if (config.enableQueue) {
|
|
@@ -29,7 +29,7 @@ class CacheManager {
|
|
|
29
29
|
if (config.enableBalanceCache !== false && config.balanceModule) {
|
|
30
30
|
this.balanceCache = new balance_cache_1.BalanceCache(this.redis, config.balanceModule, {
|
|
31
31
|
alertHandler: config.alertHandler
|
|
32
|
-
});
|
|
32
|
+
}, config.redisPublisher);
|
|
33
33
|
log.info(TAG, '✅ Balance cache initialized');
|
|
34
34
|
}
|
|
35
35
|
// Initialize Price Cache
|
|
@@ -28,7 +28,7 @@ export interface BalanceData {
|
|
|
28
28
|
*/
|
|
29
29
|
export declare class BalanceCache extends BaseCache<BalanceData> {
|
|
30
30
|
private balanceModule;
|
|
31
|
-
constructor(redis: any, balanceModule: any, config?: Partial<CacheConfig
|
|
31
|
+
constructor(redis: any, balanceModule: any, config?: Partial<CacheConfig>, redisPublisher?: any);
|
|
32
32
|
/**
|
|
33
33
|
* Build Redis key for balance data
|
|
34
34
|
* Format: balance_v2:caip:hashedPubkey
|
|
@@ -47,7 +47,7 @@ function sanitizePubkey(pubkey) {
|
|
|
47
47
|
* BalanceCache - Caches blockchain balance data
|
|
48
48
|
*/
|
|
49
49
|
class BalanceCache extends base_cache_1.BaseCache {
|
|
50
|
-
constructor(redis, balanceModule, config) {
|
|
50
|
+
constructor(redis, balanceModule, config, redisPublisher) {
|
|
51
51
|
const defaultConfig = {
|
|
52
52
|
name: 'balance',
|
|
53
53
|
keyPrefix: 'balance_v2:',
|
|
@@ -71,7 +71,7 @@ class BalanceCache extends base_cache_1.BaseCache {
|
|
|
71
71
|
logCacheMisses: true,
|
|
72
72
|
logRefreshJobs: true
|
|
73
73
|
};
|
|
74
|
-
super(redis, { ...defaultConfig, ...config });
|
|
74
|
+
super(redis, { ...defaultConfig, ...config }, redisPublisher);
|
|
75
75
|
this.balanceModule = balanceModule;
|
|
76
76
|
}
|
|
77
77
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/pioneer-cache",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.1",
|
|
4
4
|
"description": "Unified caching system for Pioneer platform with Redis backend",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@pioneer-platform/loggerdog": "8.11.0",
|
|
18
|
-
"@pioneer-platform/pioneer-discovery": "8.
|
|
19
|
-
"@pioneer-platform/pioneer-caip": "9.21.0",
|
|
18
|
+
"@pioneer-platform/pioneer-discovery": "8.45.1",
|
|
20
19
|
"@pioneer-platform/default-redis": "8.11.7",
|
|
21
|
-
"@pioneer-platform/redis-queue": "8.12.17"
|
|
20
|
+
"@pioneer-platform/redis-queue": "8.12.17",
|
|
21
|
+
"@pioneer-platform/pioneer-caip": "9.21.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/jest": "^29.5.0",
|
package/src/core/base-cache.ts
CHANGED
|
@@ -46,6 +46,7 @@ export abstract class BaseCache<T> {
|
|
|
46
46
|
protected config: CacheConfig;
|
|
47
47
|
protected queueInitialized: boolean = false;
|
|
48
48
|
protected TAG: string;
|
|
49
|
+
protected redisPublisher?: any; // Optional Redis publisher for WebSocket events
|
|
49
50
|
|
|
50
51
|
// Cache for stats (to avoid expensive SCAN operations on every health check)
|
|
51
52
|
private cachedStats: CacheStats | null = null;
|
|
@@ -56,9 +57,10 @@ export abstract class BaseCache<T> {
|
|
|
56
57
|
// Tracks in-flight network requests to prevent duplicate API calls
|
|
57
58
|
private pendingFetches: Map<string, Promise<T>> = new Map();
|
|
58
59
|
|
|
59
|
-
constructor(redis: any, config: CacheConfig) {
|
|
60
|
+
constructor(redis: any, config: CacheConfig, redisPublisher?: any) {
|
|
60
61
|
this.redis = redis;
|
|
61
62
|
this.config = config;
|
|
63
|
+
this.redisPublisher = redisPublisher;
|
|
62
64
|
this.TAG = ` | ${config.name}Cache | `;
|
|
63
65
|
|
|
64
66
|
// Initialize queue if enabled
|
|
@@ -27,6 +27,7 @@ import type { CacheAlertHandler } from '../types';
|
|
|
27
27
|
export interface CacheManagerConfig {
|
|
28
28
|
redis: any;
|
|
29
29
|
redisQueue?: any; // Dedicated Redis client for blocking queue operations (brpop, etc.)
|
|
30
|
+
redisPublisher?: any; // Optional: Redis publisher for WebSocket balance update events
|
|
30
31
|
balanceModule?: any; // Optional: if not provided, balance cache won't be initialized
|
|
31
32
|
markets?: any; // Optional: if not provided, price cache won't be initialized
|
|
32
33
|
networkModules?: Map<string, any>; // Optional: network modules for staking cache (keyed by networkId)
|
|
@@ -64,7 +65,7 @@ export class CacheManager {
|
|
|
64
65
|
if (config.enableBalanceCache !== false && config.balanceModule) {
|
|
65
66
|
this.balanceCache = new BalanceCache(this.redis, config.balanceModule, {
|
|
66
67
|
alertHandler: config.alertHandler
|
|
67
|
-
});
|
|
68
|
+
}, config.redisPublisher);
|
|
68
69
|
log.info(TAG, '✅ Balance cache initialized');
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -75,7 +75,7 @@ export interface BalanceData {
|
|
|
75
75
|
export class BalanceCache extends BaseCache<BalanceData> {
|
|
76
76
|
private balanceModule: any;
|
|
77
77
|
|
|
78
|
-
constructor(redis: any, balanceModule: any, config?: Partial<CacheConfig
|
|
78
|
+
constructor(redis: any, balanceModule: any, config?: Partial<CacheConfig>, redisPublisher?: any) {
|
|
79
79
|
const defaultConfig: CacheConfig = {
|
|
80
80
|
name: 'balance',
|
|
81
81
|
keyPrefix: 'balance_v2:',
|
|
@@ -100,7 +100,7 @@ export class BalanceCache extends BaseCache<BalanceData> {
|
|
|
100
100
|
logRefreshJobs: true
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
-
super(redis, { ...defaultConfig, ...config });
|
|
103
|
+
super(redis, { ...defaultConfig, ...config }, redisPublisher);
|
|
104
104
|
this.balanceModule = balanceModule;
|
|
105
105
|
}
|
|
106
106
|
|