Spaces:
Running
Running
Download source/teaql-ts/tests/local-cache.test.ts from teaql/browser-sqlite-playground: direct link, hf CLI and curl.
- Browser
- Download file 615 Bytes
-
https://huggingface.co/spaces/teaql/browser-sqlite-playground/resolve/main/source/teaql-ts/tests/local-cache.test.ts
- Command line
-
hf download hf://spaces/teaql/browser-sqlite-playground/source/teaql-ts/tests/local-cache.test.ts
-
curl -L -o local-cache.test.ts https://huggingface.co/spaces/teaql/browser-sqlite-playground/resolve/main/source/teaql-ts/tests/local-cache.test.ts
615 Bytes
| import { LocalCache } from '../src/core/local-cache'; | |
| describe('LocalCache', () => { | |
| beforeEach(() => jest.useFakeTimers()); | |
| afterEach(() => jest.useRealTimers()); | |
| it('shares values, removes entries, and expires TTL entries', () => { | |
| const cache = new LocalCache(); | |
| cache.put('persistent', { id: 7 }); | |
| expect(cache.get<{ id: number }>('persistent')).toEqual({ id: 7 }); | |
| cache.remove('persistent'); | |
| expect(cache.get('persistent')).toBeUndefined(); | |
| cache.put('temporary', 'value', 1); | |
| jest.advanceTimersByTime(1_000); | |
| expect(cache.get('temporary')).toBeUndefined(); | |
| }); | |
| }); | |