Registry / database / parse-cache-memory

parse-cache-memory

JSON →
library2.1.0jsnpmunverified

In-memory caching layer for Parse Server queries using LRU cache. Current version: 2.1.0. Provides drop-in cache methods (findCache, getCache, countCache, etc.) that replace standard Parse Query calls. Key differentiators: automatic cache invalidation on data mutations, configurable TTL and size, built-in debug mode, and cache statistics tracking. Lightweight without external cache dependencies.

npm install parse-cache-memory
INSTALL
IMPORT
SIG · PARSE-CACHE-MEMORY
P
parse-cache-memory
databasejavascriptv2.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.

parseCacheInit
const { parseCacheInit } = require('parse-cache-memory');
const parseCacheMemory = require('parse-cache-memory'); parseCacheMemory.parseCacheInit();
CommonJS only; no default export. Must destructure or access as property of require.
ParseCache
const { ParseCache } = require('parse-cache-memory');
Export available starting from v2? Not documented. Use parseCacheInit function instead.
parseCacheInit (with options)
const { parseCacheInit } = require('parse-cache-memory'); parseCacheInit({ max: 500, ttl: 60000 });
const { parseCacheInit } = require('parse-cache-memory'); parseCacheInit({ maxItems: 500 });
Correct option name is 'max' not 'maxItems' or 'maxSize' (though maxSize is also accepted). Options are passed as object.

Initializes the cache with custom options and demonstrates a basic cached query using findCache().

const { parseCacheInit } = require('parse-cache-memory'); const Parse = require('parse/node'); // Initialize Parse server Parse.initialize('appId', 'jsKey', 'masterKey'); Parse.serverURL = 'http://localhost:1337/parse'; // Initialize cache with custom options parseCacheInit({ max: 1000, ttl: 1000 * 60 * 10, // 10 minutes allowStale: false, updateAgeOnGet: true, resetCacheOnSaveAndDestroy: false, debug: false }); // Use cache methods async function example() { const query = new Parse.Query('GameScore'); query.equalTo('playerName', 'Dan Stemkoski'); const results = await query.findCache({ useMasterKey: true }); console.log('Results from cache:', results); }
Debug
Known issues
breakingparseCacheInit must be called before using any cache methods; otherwise methods will throw 'ParseCache is not defined'.
fix
Ensure parseCacheInit() is called once at application startup before any Parse.Query cache methods.
affects: >=1.0.0
gotchaCached methods (e.g., findCache) do not support all Parse Query options like subqueries or include pointers; behavior may be inconsistent.
fix
Use standard Parse Query methods for complex queries and revert to cache methods only for simple fetches.
affects: >=1.0.0
gotchaCache is in-memory only; restarting the server clears all cached data.
fix
No fix; design applications to tolerate cold cache or use external cache like Redis if persistence is needed.
affects: >=1.0.0
deprecatedOption 'maxSize' is deprecated in favor of 'max' to match underlying lru-cache API.
fix
Use 'max' option instead of 'maxSize'.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'findCache' of undefined
parseCacheInit() not called or called after query creation.
fix
Ensure parseCacheInit() is called at the start of your application before any Parse.Query is instantiated.
ParseCache is not defined
parseCacheInit function not imported correctly.
fix
Use const { parseCacheInit } = require('parse-cache-memory'); then call parseCacheInit();
TypeError: parseCacheInit is not a function
Default import or wrong import style.
fix
Use require('parse-cache-memory').parseCacheInit or destructure correctly.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
parserequiredPeer dependency; requires Parse Server or Parse SDK
Agent activity
7 hits · last 30 days
node
6
Resources
parse-cache-memory — npm install parse-cache-memory · libregistry