forge-sql-orm
Version:
Drizzle ORM integration for Atlassian @forge/sql. Provides a custom driver, schema migration, two levels of caching (local and global via @forge/kvs), optimistic locking, and query analysis.
56 lines • 2.2 kB
TypeScript
import { Query } from "drizzle-orm";
import { AnyMySqlTable } from "drizzle-orm/mysql-core";
import { ForgeSqlOrmOptions } from "../core/ForgeSQLQueryBuilder";
/**
* Generates a hash key for a query based on its SQL and parameters.
*
* @param query - The Drizzle query object
* @returns 32-character hexadecimal hash
*/
export declare function hashKey(query: Query): string;
/**
* Clears cache for a specific table.
* Uses cache context if available, otherwise clears immediately.
*
* @param schema - The table schema to clear cache for
* @param options - ForgeSQL ORM options
*/
export declare function clearCache<T extends AnyMySqlTable>(schema: T, options: ForgeSqlOrmOptions): Promise<void>;
/**
* Clears cache for multiple tables with retry logic and performance logging.
*
* @param tables - Array of table names to clear cache for
* @param options - ForgeSQL ORM options
* @returns Promise that resolves when cache clearing is complete
*/
export declare function clearTablesCache(tables: string[], options: ForgeSqlOrmOptions): Promise<void>;
/**
* Clears expired cache entries with retry logic and performance logging.
*
* @param options - ForgeSQL ORM options
* @returns Promise that resolves when expired cache clearing is complete
*/
export declare function clearExpiredCache(options: ForgeSqlOrmOptions): Promise<void>;
/**
* Retrieves data from cache if it exists and is not expired.
*
* @param query - Query object with toSQL method
* @param options - ForgeSQL ORM options
* @returns Cached data if found and valid, undefined otherwise
*/
export declare function getFromCache<T>(query: {
toSQL: () => Query;
}, options: ForgeSqlOrmOptions): Promise<T | undefined>;
/**
* Stores query results in cache with specified TTL.
*
* @param query - Query object with toSQL method
* @param options - ForgeSQL ORM options
* @param results - Data to cache
* @param cacheTtl - Time to live in seconds
* @returns Promise that resolves when data is stored in cache
*/
export declare function setCacheResult(query: {
toSQL: () => Query;
}, options: ForgeSqlOrmOptions, results: unknown, cacheTtl: number): Promise<void>;
//# sourceMappingURL=cacheUtils.d.ts.map