Registry / database / flk-core

flk-core

JSON →
library0.1.67jsnpmunverified

Browser localStorage-based caching library, part of the Falak framework ecosystem. Current stable version: 0.1.67. Provides a simple API (set, get, has, remove, clear) with automatic serialization of objects/arrays, optional encryption of stored values, and configurable expiration using timestamps. Designed for use with DI container; supports ESM/CommonJS. Lightweight, no external dependencies, encrypts values by default via flk-crypto. Differentiates from general caching libraries by deep Falak integration and encryption-at-rest built-in.

npm install flk-core
INSTALL
IMPORT
SIG · FLK-CORE
F
flk-core
databasejavascriptv0.1.67
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Cache
✓ import { getCache } from 'flk-cache';
✗ import Cache from 'flk-cache';
Default export not provided; use named export 'getCache' or DI resolve pattern.
DI
✓ import { DI } from 'flk-core'; const cache = DI.resolve('cache');
✗ const cache = require('flk-cache');
Cache is typically resolved through DI, not imported directly. flk-core provides the DI container.
getCache
✓ import { getCache } from 'flk-cache'; const cache = getCache();
✗ const { Cache } = require('flk-cache');
getCache is a factory function; do not use Cache as constructor.

Demonstrates basic CRUD operations: set, get, has, remove, clear with object support and expiration.

import { DI } from 'flk-core'; import 'flk-cache'; // Ensure flk-cache is registered with DI const cache = DI.resolve('cache'); // Set a value cache.set('username', 'john_doe'); // Get a value const username = cache.get('username'); console.log(username); // 'john_doe' // Set with expiration (1 hour from now) const oneHour = Date.now() + 3600000; cache.set('session', { token: 'abc123' }, oneHour); // Check existence if (cache.has('username')) { console.log('Key exists'); } // Remove a key cache.remove('username'); // Clear all cache cache.clear();
Debug
Known issues
gotchaCache values are encrypted by default if flk-crypto is installed. Encrypted values are not human-readable in localStorage.
fix
Set 'encryptValues' to false in flk-config under 'cache' key to disable encryption.
affects: >=0.1.0
gotchaThe set() method's expiresAt parameter expects a timestamp in milliseconds (e.g., Date.now() + duration), not a duration string.
fix
Use Cache.FOR_ONE_HOUR constant or calculate: Date.now() + 3600000.
affects: >=0.1.0
deprecatedUsing require('flk-cache') is deprecated. Import as ESM module.
fix
Use import { getCache } from 'flk-cache'.
affects: >=0.1.60
gotchaThe cache relies on browser localStorage; not available in Node.js without a polyfill.
fix
Use only in browser environment or provide localStorage polyfill for Node.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: DI.resolve is not a function
flk-core (DI container) is not installed or imported before flk-cache.
fix
Install and import flk-core first: import { DI } from 'flk-core'; import 'flk-cache';
Error: Module "flk-cache" does not provide a default export
Attempting default import when the module only exports named exports.
fix
Use named import: import { getCache } from 'flk-cache';
ReferenceError: localStorage is not defined
Running in environment without localStorage (e.g., Node.js, SSR).
fix
Use a polyfill like 'localstorage-polyfill' or avoid using cache server-side.
Error: Cache value must be a valid timestamp for expiresAt
Passing a non-number (e.g., string) as expiresAt parameter.
fix
Provide a numeric timestamp: cache.set('key', value, Date.now() + 60000);
Upgrade
Version history
0.1.67latest on npm
Audit
Dependencies
flk-cryptooptionalEncrypts cache values when encryptValues config is true
Agent activity
23 hits · last 30 days
node
20
Anthropic
1
OpenAI (training)
1
Resources
flk-core — npm install flk-core · libregistry