Spaces:
Sleeping
Sleeping
| import { WeakLRUCache } from 'weak-lru-cache'; | |
| import { RegulationSolution, SpartitoMeasure } from '../../src/starry'; | |
| const lruCache = new WeakLRUCache(); | |
| interface SolutionStore { | |
| get: (key: string) => Promise<RegulationSolution>; | |
| set: (key: string, val: RegulationSolution) => Promise<void>; | |
| batchGet: (keys: string[]) => Promise<RegulationSolution[]>; | |
| } | |
| // 默认store | |
| const DefaultSolutionStore: SolutionStore = { | |
| async get(key: string) { | |
| return lruCache.getValue(key) as RegulationSolution; | |
| }, | |
| async set(key: string, val: RegulationSolution) { | |
| lruCache.setValue(key, val); | |
| }, | |
| async batchGet(keys: string[]) { | |
| return keys.map((key) => lruCache.getValue(key) as RegulationSolution); | |
| }, | |
| }; | |
| const enum MeasureStatus { | |
| Discard = -1, | |
| Solved = 0, | |
| Issue = 1, | |
| Fatal = 2, | |
| } | |
| interface IssueMeasure { | |
| scoreId: string; | |
| measureIndex: number; | |
| measure: SpartitoMeasure; | |
| status: MeasureStatus; | |
| } | |
| type SaveIssueMeasure = (data: Omit<IssueMeasure, 'scoreId'>) => void; | |
| export { SolutionStore, DefaultSolutionStore, MeasureStatus, IssueMeasure, SaveIssueMeasure }; | |