Registry / storage / koop-cache-memory

koop-cache-memory

JSON →
library1.1.0jsnpmunverified

An in-memory cache module for Koop, a spatial data server. Version 1.1.0 is the current stable release. It provides a default cache for Koop instances, storing GeoJSON features and their metadata in a JavaScript object. The cache supports insert, update, upsert, delete, retrieve, and streaming operations, with optional TTL expiry. Unlike persistent caches, this is ephemeral and suitable for development or single-process deployments. No breaking changes documented; used primarily as a dependency of the Koop core.

npm install koop-cache-memory
INSTALL
IMPORT
SIG · KOOP-CACHE-MEMORY
K
koop-cache-memory
storagejavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
const cache = require('koop-cache-memory')
import cache from 'koop-cache-memory'
Koop ecosystem traditionally uses CommonJS; the package does not export ESM.

Installs and registers the memory cache with a Koop instance, inserts GeoJSON with metadata, and retrieves it.

const Koop = require('koop'); const koop = new Koop(); const cache = require('koop-cache-memory'); // Register the cache with Koop koop.register(cache); // Insert GeoJSON into cache const geojson = { type: 'FeatureCollection', features: [], metadata: { name: 'Example', description: 'Sample data' } }; cache.insert('my-key', geojson, { ttl: 3600 }, (err) => { if (err) return console.error(err); console.log('Cached successfully'); // Retrieve cached data cache.retrieve('my-key', {}, (err, data) => { if (err) return console.error(err); console.log('Retrieved:', data.metadata.name); }); });
Debug
Known issues
gotchaCache is in-memory and data is lost on process restart.
fix
Use a persistent cache (e.g., koop-cache-redis) for production.
affects: >=1.0.0
gotchainsert callback returns error if key already exists; it does not overwrite.
fix
Use upsert to overwrite or delete first.
affects: >=1.0.0
gotchaCatalog.insert is called automatically on cache.insert; manually calling it with same key returns error.
fix
Use catalog.update to modify metadata after insertion.
affects: >=1.0.0
gotchaTTL option is in seconds, not milliseconds.
fix
Ensure TTL values are provided as seconds (e.g., 3600 for 1 hour).
affects: >=1.0.0
Errors
Common errors & fixes
Error: insert callback: Error: cache key already exists
Trying to insert a key that already exists in the cache.
fix
Use cache.upsert() or call cache.delete(key) before cache.insert().
TypeError: cache.insert is not a function
The module was not registered with a Koop instance; it expects to be registered to be functional.
fix
Register the cache with koop.register(cache) after requiring it.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
koopoptionalDesigned to be registered with a Koop instance; not a standalone cache.
Agent activity
15 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
koop-cache-memory — npm install koop-cache-memory · libregistry