@levrbet/shared 0.2.81 → 0.3.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/dist/core/config/urls.js +4 -4
- package/dist/core/config/urls.js.map +1 -1
- package/dist/core/utils/game.utils.d.ts +2 -0
- package/dist/core/utils/game.utils.js +69 -1
- package/dist/core/utils/game.utils.js.map +1 -1
- package/dist/server/oracle/config/game-periods/providers/lsports.periods.js +3 -3
- package/dist/server/oracle/config/game-periods/providers/lsports.periods.js.map +1 -1
- package/dist/server/oracle/config/game-periods/providers/optic-odds.periods.d.ts +4 -27
- package/dist/server/oracle/config/game-periods/providers/optic-odds.periods.js +4 -27
- package/dist/server/oracle/config/game-periods/providers/optic-odds.periods.js.map +1 -1
- package/dist/server/oracle/config/game-periods/sports.config.js +8 -65
- package/dist/server/oracle/config/game-periods/sports.config.js.map +1 -1
- package/dist/server/oracle/config/game-periods/types.d.ts +2 -5
- package/dist/server/oracle/config/game-periods/types.js +0 -1
- package/dist/server/oracle/config/game-periods/types.js.map +1 -1
- package/dist/server/oracle/redis-cache-manager/cache.keys.utils.d.ts +45 -74
- package/dist/server/oracle/redis-cache-manager/cache.keys.utils.js +65 -120
- package/dist/server/oracle/redis-cache-manager/cache.keys.utils.js.map +1 -1
- package/dist/server/oracle/redis-cache-manager/game.query.engine.d.ts +90 -0
- package/dist/server/oracle/redis-cache-manager/game.query.engine.js +436 -0
- package/dist/server/oracle/redis-cache-manager/game.query.engine.js.map +1 -0
- package/dist/server/oracle/redis-cache-manager/index.d.ts +2 -3
- package/dist/server/oracle/redis-cache-manager/index.js +2 -3
- package/dist/server/oracle/redis-cache-manager/index.js.map +1 -1
- package/dist/server/oracle/redis-cache-manager/market.query.engine.d.ts +50 -97
- package/dist/server/oracle/redis-cache-manager/market.query.engine.js +310 -467
- package/dist/server/oracle/redis-cache-manager/market.query.engine.js.map +1 -1
- package/dist/server/oracle/types/providers/game-clock/index.d.ts +1 -1
- package/dist/server/oracle/types/providers/game-clock/index.js +1 -1
- package/dist/server/oracle/types/providers/game-clock/index.js.map +1 -1
- package/dist/server/{utils/game_progress → oracle/types/providers/game-clock}/parser.d.ts +7 -1
- package/dist/server/{utils/game_progress → oracle/types/providers/game-clock}/parser.js +13 -2
- package/dist/server/oracle/types/providers/game-clock/parser.js.map +1 -0
- package/dist/server/utils/index.d.ts +0 -1
- package/dist/server/utils/index.js +0 -1
- package/dist/server/utils/index.js.map +1 -1
- package/package.json +5 -4
- package/scripts/setup-prisma.js +0 -0
- package/dist/server/oracle/redis-cache-manager/game.cache.service.d.ts +0 -185
- package/dist/server/oracle/redis-cache-manager/game.cache.service.js +0 -712
- package/dist/server/oracle/redis-cache-manager/game.cache.service.js.map +0 -1
- package/dist/server/oracle/redis-cache-manager/game.progress.d.ts +0 -4
- package/dist/server/oracle/redis-cache-manager/game.progress.js +0 -27
- package/dist/server/oracle/redis-cache-manager/game.progress.js.map +0 -1
- package/dist/server/oracle/redis-cache-manager/market.cache.service.d.ts +0 -87
- package/dist/server/oracle/redis-cache-manager/market.cache.service.js +0 -139
- package/dist/server/oracle/redis-cache-manager/market.cache.service.js.map +0 -1
- package/dist/server/utils/game_progress/caclulate.game.progress.d.ts +0 -6
- package/dist/server/utils/game_progress/caclulate.game.progress.js +0 -96
- package/dist/server/utils/game_progress/caclulate.game.progress.js.map +0 -1
- package/dist/server/utils/game_progress/game.utils.d.ts +0 -2
- package/dist/server/utils/game_progress/game.utils.js +0 -65
- package/dist/server/utils/game_progress/game.utils.js.map +0 -1
- package/dist/server/utils/game_progress/index.d.ts +0 -5
- package/dist/server/utils/game_progress/index.js +0 -84
- package/dist/server/utils/game_progress/index.js.map +0 -1
- package/dist/server/utils/game_progress/parser.js.map +0 -1
|
@@ -1,153 +1,98 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @memberof RedisCacheKeysUtils
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Redis cache key constants and helper functions
|
|
6
5
|
*/
|
|
7
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
exports.getGamesKeyByChainId = exports.getMarketOddsListHashKey = exports.getMarketOddsField = exports.getCachedLevrByFixtureIdKey = exports.marketOddsKey = exports.gameToMarketOfOddsInCache = exports.getGameScoreByFixtureIdHash = exports.gameIdsToFixtureIds = exports.gameIdsToLevrFixtureIdsMap = exports.GameCollectionKeys = exports.queueBlockHashKey = exports.levrIdToProviderIds = exports.providerFixtureIdToLevrId = exports.getMarketKeyWithGameUniqueIdMarketType = exports.getOddsListKey = exports.getGameHashKey = exports.getScoreHashKey = exports.RedisNumStates = exports.game_index_name = exports.market_index_name = exports.levrOddsListKey = exports.levrMarketsHashKey = exports.levrGamesHashKey = void 0;
|
|
8
|
+
// =====================================================
|
|
9
|
+
// ACTIVE KEYS
|
|
10
|
+
// =====================================================
|
|
11
|
+
// Redis hash key prefixes
|
|
12
|
+
exports.levrGamesHashKey = "levr:games:"; // redis hash for games
|
|
13
|
+
exports.levrMarketsHashKey = "levr:markets:"; // redis hash for markets
|
|
14
|
+
exports.levrOddsListKey = "levr:odds:list:"; // redis list for odds
|
|
15
|
+
// Cache Index Names
|
|
16
|
+
exports.market_index_name = "levr:markets_idx";
|
|
17
|
+
exports.game_index_name = "levr:games_idx";
|
|
18
|
+
// Enums
|
|
17
19
|
var RedisNumStates;
|
|
18
20
|
(function (RedisNumStates) {
|
|
19
21
|
RedisNumStates[RedisNumStates["success"] = 1] = "success";
|
|
20
22
|
RedisNumStates[RedisNumStates["failure"] = 0] = "failure";
|
|
21
23
|
})(RedisNumStates || (exports.RedisNumStates = RedisNumStates = {}));
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
// Score cache key prefix
|
|
25
|
+
const levrScoresKey = "levr:scores:";
|
|
24
26
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @
|
|
27
|
+
* Get the Redis key for a game score by gameObjectId
|
|
28
|
+
* @param gameObjectId - The game object ID
|
|
29
|
+
* @returns Redis key for the score
|
|
27
30
|
*/
|
|
28
|
-
|
|
31
|
+
const getScoreHashKey = (gameObjectId) => `${levrScoresKey}${gameObjectId}`;
|
|
32
|
+
exports.getScoreHashKey = getScoreHashKey;
|
|
29
33
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @description stores the list moneylines for the given gameId appended to it
|
|
34
|
+
* Get the Redis hash key for a game by gameObjectId
|
|
32
35
|
*/
|
|
33
|
-
const
|
|
36
|
+
const getGameHashKey = (gameObjectId) => `${exports.levrGamesHashKey}${gameObjectId}`;
|
|
37
|
+
exports.getGameHashKey = getGameHashKey;
|
|
34
38
|
/**
|
|
35
|
-
*
|
|
36
|
-
* @
|
|
39
|
+
* Get the Redis LIST key for odds by gameMarketId
|
|
40
|
+
* @param gameMarketId - The game market identifier
|
|
41
|
+
* @returns Redis key for the odds list
|
|
37
42
|
*/
|
|
38
|
-
|
|
43
|
+
const getOddsListKey = (gameMarketId) => `${exports.levrOddsListKey}${gameMarketId}`;
|
|
44
|
+
exports.getOddsListKey = getOddsListKey;
|
|
39
45
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @description stores the list of all levr games in cache
|
|
46
|
+
* Get the Redis hash key for market by gameUniqueId and marketType
|
|
42
47
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
const getMarketKeyWithGameUniqueIdMarketType = (gameUniqueId, marketType) => {
|
|
49
|
+
return `${exports.levrMarketsHashKey}${gameUniqueId}:${marketType}`;
|
|
50
|
+
};
|
|
51
|
+
exports.getMarketKeyWithGameUniqueIdMarketType = getMarketKeyWithGameUniqueIdMarketType;
|
|
52
|
+
// =====================================================
|
|
53
|
+
// REDUNDANT KEYS - No longer used after game.cache.service removal
|
|
54
|
+
// TODO: Remove once confirmed not needed elsewhere
|
|
55
|
+
// =====================================================
|
|
56
|
+
/** @deprecated Not used after game.cache.service removal */
|
|
57
|
+
exports.providerFixtureIdToLevrId = "provider_fixture_id_to_levrId";
|
|
58
|
+
/** @deprecated Not used after game.cache.service removal */
|
|
59
|
+
exports.levrIdToProviderIds = "levr_id_to_provider_ids";
|
|
60
|
+
/** @deprecated Not used after game.cache.service removal */
|
|
61
|
+
exports.queueBlockHashKey = "queue_block_key";
|
|
62
|
+
/** @deprecated Not used after game.cache.service removal */
|
|
63
|
+
var GameCollectionKeys;
|
|
64
|
+
(function (GameCollectionKeys) {
|
|
65
|
+
GameCollectionKeys["activeGamesHash"] = "active_games_hash";
|
|
66
|
+
GameCollectionKeys["postGamesHash"] = "post_games_hash";
|
|
67
|
+
})(GameCollectionKeys || (exports.GameCollectionKeys = GameCollectionKeys = {}));
|
|
68
|
+
/** @deprecated Not used after game.cache.service removal */
|
|
69
|
+
exports.gameIdsToLevrFixtureIdsMap = "game_ids_to_levr_ids";
|
|
70
|
+
/** @deprecated Not used after game.cache.service removal */
|
|
71
|
+
exports.gameIdsToFixtureIds = "game_ids_to_fixture_ids";
|
|
72
|
+
/** @deprecated Not used after game.cache.service removal - replaced by getScoreHashKey */
|
|
73
|
+
exports.getGameScoreByFixtureIdHash = "game_scores_by_fixture_id_hash";
|
|
74
|
+
/** @deprecated Not used after game.cache.service removal */
|
|
51
75
|
exports.gameToMarketOfOddsInCache = "game_to_market_ids_of_odds_in_cache_";
|
|
52
|
-
/**
|
|
53
|
-
* @memberof RedisCacheKeysUtils
|
|
54
|
-
* @description stores the game period info for the given gameId appended to it
|
|
55
|
-
* @example {
|
|
56
|
-
* gameId: 1,
|
|
57
|
-
* period: 1,
|
|
58
|
-
* timeUpdated: 1714857600
|
|
59
|
-
* }
|
|
60
|
-
*/
|
|
61
|
-
exports.baseBallGamePeriodInfo = "baseball_game_period_info";
|
|
62
|
-
/**
|
|
63
|
-
* @memberof RedisCacheKeysUtils
|
|
64
|
-
* @description stores the full time odds for the given gameId appended to it
|
|
65
|
-
* @example {
|
|
66
|
-
* gameId: 1,
|
|
67
|
-
* odds:
|
|
68
|
-
* }
|
|
69
|
-
*/
|
|
76
|
+
/** @deprecated Not used after game.cache.service removal */
|
|
70
77
|
exports.marketOddsKey = "market_odds";
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* @memberof RedisCacheKeysUtils
|
|
75
|
-
* @description stores the time invalidation for the cache
|
|
76
|
-
*/
|
|
77
|
-
exports.cacheTimeInvalidation = 60; // 1 minute.
|
|
78
|
-
/** @audit levr fixture ids must be the same for games across all chains */
|
|
79
|
-
/**
|
|
80
|
-
* @memberof RedisCacheKeysUtils
|
|
81
|
-
* @param gameId
|
|
82
|
-
* @returns
|
|
83
|
-
*/
|
|
84
|
-
const getMoneylineByGameIdKey = (gameId) => {
|
|
85
|
-
return `${moneyLineByGameId}${gameId.toString()}`;
|
|
86
|
-
};
|
|
87
|
-
exports.getMoneylineByGameIdKey = getMoneylineByGameIdKey;
|
|
88
|
-
/**
|
|
89
|
-
* @memberof RedisCacheKeysUtils
|
|
90
|
-
* @param gameId
|
|
91
|
-
* @returns
|
|
92
|
-
*/
|
|
93
|
-
const getCacheLevrGameIdKey = (gameId) => {
|
|
94
|
-
return `${levrGame}${gameId.toString()}`;
|
|
95
|
-
};
|
|
96
|
-
exports.getCacheLevrGameIdKey = getCacheLevrGameIdKey;
|
|
97
|
-
/**
|
|
98
|
-
* @memberof RedisCacheKeysUtils
|
|
99
|
-
* @param fixtureId
|
|
100
|
-
* @returns
|
|
101
|
-
*/
|
|
78
|
+
/** @deprecated Not used after game.cache.service removal */
|
|
79
|
+
const levrGame = "levr_game_";
|
|
80
|
+
/** @deprecated Not used after game.cache.service removal */
|
|
102
81
|
const getCachedLevrByFixtureIdKey = (fixtureId, chainId) => {
|
|
103
82
|
return `${levrGame}${fixtureId}_${chainId.toString()}`;
|
|
104
83
|
};
|
|
105
84
|
exports.getCachedLevrByFixtureIdKey = getCachedLevrByFixtureIdKey;
|
|
85
|
+
/** @deprecated Not used after game.cache.service removal */
|
|
106
86
|
const getMarketOddsField = (gameUniqueId, marketType) => {
|
|
107
87
|
return `${gameUniqueId}:${marketType}`;
|
|
108
88
|
};
|
|
109
89
|
exports.getMarketOddsField = getMarketOddsField;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const getLevrFixtureIdToProviderIdsKey = (levrFixtureId) => {
|
|
115
|
-
return `${exports.levrIdToProviderIds}${levrFixtureId}`;
|
|
116
|
-
};
|
|
117
|
-
exports.getLevrFixtureIdToProviderIdsKey = getLevrFixtureIdToProviderIdsKey;
|
|
118
|
-
const getMarketOddsByMarketIdKey = (marketId) => {
|
|
119
|
-
return `${exports.marketByMarketIdKey}${marketId}`;
|
|
120
|
-
};
|
|
121
|
-
exports.getMarketOddsByMarketIdKey = getMarketOddsByMarketIdKey;
|
|
122
|
-
const getMarketOddsByGameUniqueIdKeyAndMarketType = (gameUniqueId) => {
|
|
123
|
-
return `${exports.marketByGameUniqueIdKeyAndMarketType}${gameUniqueId}`;
|
|
124
|
-
};
|
|
125
|
-
exports.getMarketOddsByGameUniqueIdKeyAndMarketType = getMarketOddsByGameUniqueIdKeyAndMarketType;
|
|
126
|
-
const getGameToMarketsOfOddsInCacheKey = (gameUniqueId) => {
|
|
127
|
-
return `${exports.gameToMarketOfOddsInCache}${gameUniqueId}`;
|
|
128
|
-
};
|
|
129
|
-
exports.getGameToMarketsOfOddsInCacheKey = getGameToMarketsOfOddsInCacheKey;
|
|
130
|
-
const getCompletedMarketsKey = (marketType) => {
|
|
131
|
-
return `completed_markets:${marketType}`;
|
|
132
|
-
};
|
|
133
|
-
exports.getCompletedMarketsKey = getCompletedMarketsKey;
|
|
134
|
-
const getCompletedMarketsField = (gameUniqueId, marketType) => {
|
|
135
|
-
return `${gameUniqueId}:${marketType}:completed`;
|
|
136
|
-
};
|
|
137
|
-
exports.getCompletedMarketsField = getCompletedMarketsField;
|
|
90
|
+
/** @deprecated Not used after game.cache.service removal */
|
|
91
|
+
const getMarketOddsListHashKey = (marketObjectId) => `${exports.levrOddsListKey}${marketObjectId}`;
|
|
92
|
+
exports.getMarketOddsListHashKey = getMarketOddsListHashKey;
|
|
93
|
+
/** @deprecated Not used after game.cache.service removal */
|
|
138
94
|
const getGamesKeyByChainId = (gameCollectionKey, chainId) => {
|
|
139
95
|
return `${gameCollectionKey}_${chainId.toString()}`;
|
|
140
96
|
};
|
|
141
97
|
exports.getGamesKeyByChainId = getGamesKeyByChainId;
|
|
142
|
-
// auth
|
|
143
|
-
const getRevokedApiKey = (keyId) => {
|
|
144
|
-
return `revoked:${keyId}`;
|
|
145
|
-
};
|
|
146
|
-
exports.getRevokedApiKey = getRevokedApiKey;
|
|
147
|
-
/// new key
|
|
148
|
-
const getMarketKeyWithGameUniqueIdMarketType = (gameUniqueId, marketType) => {
|
|
149
|
-
return `markets_unique_id:${gameUniqueId}:${marketType}`;
|
|
150
|
-
};
|
|
151
|
-
exports.getMarketKeyWithGameUniqueIdMarketType = getMarketKeyWithGameUniqueIdMarketType;
|
|
152
|
-
exports.market_index_name = "markets_unique_id_idx";
|
|
153
98
|
//# sourceMappingURL=cache.keys.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.keys.utils.js","sourceRoot":"","sources":["../../../../src/server/oracle/redis-cache-manager/cache.keys.utils.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"cache.keys.utils.js","sourceRoot":"","sources":["../../../../src/server/oracle/redis-cache-manager/cache.keys.utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,wDAAwD;AACxD,cAAc;AACd,wDAAwD;AAExD,0BAA0B;AACb,QAAA,gBAAgB,GAAG,aAAa,CAAA,CAAC,uBAAuB;AACxD,QAAA,kBAAkB,GAAG,eAAe,CAAA,CAA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
import type { LevrScores } from "../../../core";
|
|
4
|
+
export interface GameSearchQuery {
|
|
5
|
+
gameId?: number;
|
|
6
|
+
objectId?: string;
|
|
7
|
+
gamePhase?: string;
|
|
8
|
+
sportGroup?: string;
|
|
9
|
+
levrFixtureId?: string;
|
|
10
|
+
opticOddsFixtureId?: string;
|
|
11
|
+
liveScoreMatchId?: string;
|
|
12
|
+
tournamentObjectId?: string;
|
|
13
|
+
leagueObjectId?: string;
|
|
14
|
+
fixtureObjectId?: string;
|
|
15
|
+
paused?: 0 | 1;
|
|
16
|
+
lsportsFixtureId?: number;
|
|
17
|
+
chainId?: number;
|
|
18
|
+
limit?: number;
|
|
19
|
+
offset?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create game index with proper schema.
|
|
23
|
+
* Validates existing index schema and recreates if schema has changed.
|
|
24
|
+
*/
|
|
25
|
+
export declare const createGameIndex: (redis: Redis) => Promise<void>;
|
|
26
|
+
export interface UpdateGameCacheResult {
|
|
27
|
+
success: number;
|
|
28
|
+
failed: string[];
|
|
29
|
+
total: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Updates the Redis cache with an array of LevrGame objects using pipelined batch operations.
|
|
33
|
+
*
|
|
34
|
+
* @param redis - The Redis client instance used for cache operations
|
|
35
|
+
* @param games - An array of LevrGame objects to be cached
|
|
36
|
+
* @returns A Promise resolving to UpdateGameCacheResult with success/failure counts
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* This function uses Redis pipelining to efficiently batch multiple HSET operations,
|
|
40
|
+
* reducing network round trips. Large arrays are chunked to avoid memory/timeout issues.
|
|
41
|
+
* Each game is stored as a Redis hash with a key generated from the game's objectId.
|
|
42
|
+
* Date fields are converted to timestamps, booleans to "1"/"0" strings, and numbers to strings.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const redis = new Redis();
|
|
47
|
+
* const games: LevrGame[] = [...];
|
|
48
|
+
* const result = await updateGameCache(redis, games);
|
|
49
|
+
* console.log(`Updated ${result.success}/${result.total} games`);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare const updateGameCache: (redis: Redis, games: LevrGame[]) => Promise<UpdateGameCacheResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Set a game score in the Redis cache
|
|
55
|
+
* @param redis - Redis client instance
|
|
56
|
+
* @param gameObjectId - The game object ID to key the score
|
|
57
|
+
* @param score - The LevrScores object to cache
|
|
58
|
+
*/
|
|
59
|
+
export declare const setScoreCache: (redis: Redis, gameObjectId: string, score: LevrScores) => Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Get a game score from the Redis cache
|
|
62
|
+
* @param redis - Redis client instance
|
|
63
|
+
* @param gameObjectId - The game object ID to retrieve
|
|
64
|
+
* @returns The LevrScores object or null if not found
|
|
65
|
+
*/
|
|
66
|
+
export declare const getScoreCache: (redis: Redis, gameObjectId: string) => Promise<LevrScores | null>;
|
|
67
|
+
/**
|
|
68
|
+
* Get multiple game scores from the Redis cache
|
|
69
|
+
* @param redis - Redis client instance
|
|
70
|
+
* @param gameObjectIds - Array of game object IDs to retrieve
|
|
71
|
+
* @returns Map of gameObjectId to LevrScores
|
|
72
|
+
*/
|
|
73
|
+
export declare const getScoresCacheBatch: (redis: Redis, gameObjectIds: string[]) => Promise<Map<string, LevrScores>>;
|
|
74
|
+
export interface GameSearchResult {
|
|
75
|
+
games: LevrGame[];
|
|
76
|
+
total: number;
|
|
77
|
+
error?: string;
|
|
78
|
+
}
|
|
79
|
+
export declare const searchGames: (redis: Redis, params: GameSearchQuery) => Promise<GameSearchResult>;
|
|
80
|
+
export interface DropIndicesResult {
|
|
81
|
+
dropped: string[];
|
|
82
|
+
notFound: string[];
|
|
83
|
+
failed: string[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Drop game search index
|
|
87
|
+
* @param redis - Redis client instance
|
|
88
|
+
* @returns Result object with dropped, notFound, and failed indices
|
|
89
|
+
*/
|
|
90
|
+
export declare const dropGameIndex: (redis: Redis) => Promise<DropIndicesResult>;
|