import type { GamePhase, LevrGame, SportGroup } from "@prisma/client"; import type { Redis } from "ioredis"; import type { LevrScores } from "../../../core"; export interface GameSearchQuery { gameId?: number | number[]; objectId?: string | string[]; gamePhase?: string | string[]; sportGroup?: string | string[]; levrFixtureId?: string | string[]; opticOddsFixtureId?: string | string[]; liveScoreMatchId?: string | string[]; tournamentObjectId?: string | string[]; leagueObjectId?: string | string[]; fixtureObjectId?: string | string[]; paused?: 0 | 1; lsportsFixtureId?: number | number[]; chainId?: number | number[]; limit?: number; offset?: number; } /** * Create game index with proper schema. * Validates existing index schema and recreates if schema has changed. * Uses the Redis client's keyPrefix to construct the correct index name and data prefix. */ export declare const createGameIndex: (redis: Redis) => Promise; export interface UpdateGameCacheResult { success: number; failed: string[]; total: number; } /** * Updates the Redis cache with an array of LevrGame objects using pipelined batch operations. * * @param redis - The Redis client instance used for cache operations * @param games - An array of LevrGame objects to be cached * @returns A Promise resolving to UpdateGameCacheResult with success/failure counts * * @remarks * This function uses Redis pipelining to efficiently batch multiple HSET operations, * reducing network round trips. Large arrays are chunked to avoid memory/timeout issues. * Each game is stored as a Redis hash with a key generated from the game's objectId. * Date fields are converted to timestamps, booleans to "1"/"0" strings, and numbers to strings. * * @example * ```typescript * const redis = new Redis(); * const games: LevrGame[] = [...]; * const result = await updateGameCache(redis, games); * console.log(`Updated ${result.success}/${result.total} games`); * ``` */ export declare const updateGameCache: (redis: Redis, games: LevrGame[]) => Promise; /** Explicit patch interface for LevrGame - objectId required, all other fields optional */ export interface LevrGamePatch { objectId: string; gameId?: number; txHash?: string; chainId?: number; seasonType?: string; venue?: string; eventName?: string; location?: string; venueLocation?: string; gameClock?: string; gameProgressBps?: number; paused?: boolean; fixtureDate?: Date; wentLiveAt?: Date | null; homeTeam?: unknown; awayTeam?: unknown; currentPeriod?: number; actualDuration?: number; gamePhase?: GamePhase; levrFixtureId?: string; opticOddsFixtureId?: string | null; lsportsFixtureId?: string | null; liveScoreMatchId?: string | null; streamUrl?: string | null; sportGroup?: SportGroup; tournamentObjectId?: string; fixtureObjectId?: string; leagueObjectId?: string; createdAt?: Date; updatedAt?: Date; } /** * Patches games in the Redis cache by updating only the provided fields. * Unlike updateGameCache which overwrites all fields, this function only updates * the fields that are explicitly provided in each game object. * * @param redis - The Redis client instance used for cache operations * @param games - An array of partial LevrGame objects (objectId required, all other fields optional) * @returns A Promise resolving to UpdateGameCacheResult with success/failure counts */ export declare const patchGameCache: (redis: Redis, games: LevrGamePatch[]) => Promise; /** * Set a game score in the Redis cache * @param redis - Redis client instance * @param gameObjectId - The game object ID to key the score * @param score - The LevrScores object to cache */ export declare const setScoreCache: (redis: Redis, gameObjectId: string, score: LevrScores) => Promise; /** * Get a game score from the Redis cache * @param redis - Redis client instance * @param gameObjectId - The game object ID to retrieve * @returns The LevrScores object or null if not found */ export declare const getScoreCache: (redis: Redis, gameObjectId: string) => Promise; /** * Get multiple game scores from the Redis cache * @param redis - Redis client instance * @param gameObjectIds - Array of game object IDs to retrieve * @returns Map of gameObjectId to LevrScores */ export declare const getScoresCacheBatch: (redis: Redis, gameObjectIds: string[]) => Promise>; export interface GameSearchResult { games: LevrGame[]; total: number; error?: string; } /** * Searches for games in the Redis cache using RediSearch. * All filter params support single values or arrays (OR matching). * Limit auto-calculates to max(100, largestArraySize) if not specified. */ export declare const searchGames: (redis: Redis, params: GameSearchQuery) => Promise; export declare const searchGamesWithMarketsAndOdds: (redis: Redis, params: GameSearchQuery) => Promise; export interface DropIndicesResult { dropped: string[]; notFound: string[]; failed: string[]; } /** * Drop game search index * @param redis - Redis client instance * @returns Result object with dropped, notFound, and failed indices */ export declare const dropGameIndex: (redis: Redis) => Promise;