Some features were added and new using styles like this one. The package version should least 1.0.13
require('parse-cache-memory').parseCacheInit();
or
const customOptions = {
max: 1000, // maximum number of items that can be stored for each class (className)
maxSize: 10000, // total maximum number of items that can be stored across all classes
ttl: 1000 * 60 * 10, // time-to-live for items in the cache, here set to 10 minutes
allowStale: true, // determines whether items can be used after their ttl has expired
updateAgeOnGet: true, // determines whether an item's age is updated when it's retrieved using "get"
updateAgeOnHas: true, // determines whether an item's age is updated when it's checked using "has"
resetCacheOnSaveAndDestroy: false, // determines whether the cache is reset when an object is saved or destroyed
};
const ParseCache = require('parse-cache-memory').parseCacheInit(customOptions)
Sometimes I get this error, not sure if thatās related to my code implementation or a bug.
TypeError: Cannot read properties of undefined (reading 'className')
at global.Parse.Object.saveAll (C:\Users\PC\Desktop\project\backend\node_modules\parse-cache-memory\index.js:77:31)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async updateUniqueStats (C:\Users\PC\Desktop\project\backend\cloud\functions\common\updateStatsOnDelivery.js:59:7)
Node.js v18.2.0
It happens out of nowhere, even if not using the cached function. Maybe thatās because parse-cache-memory probably overrides standard Parse.Object.saveAll function.
Edit: the issue is indeed package related and happens only when Parse.Object.saveAll function is used (Tested after uninstalling the package - works fine).
During the save process if it doesnāt pass className this error will return.
If you update the package to 1.0.13, the default cache will not reset.
This mentioned provides this option resetCacheOnSaveAndDestroy: false
This error throws in some parse versions, so this is a good option for these variations.
@rgunindi
Redis support would be awesome. Some use Parse Server behind a load balancer with a lot of replicas. Need a distributed cache for that to work.
Forked your package since I wanted to add that myself, but Iām still using a single replica Parse Server so I donāt have an immediate need for it
Parse-cache-memory** is a caching library designed specifically for Parse Server queries. It helps improve performance by storing and quickly retrieving query results, reducing the need to repeatedly fetch data from the database. This customization optimizes the handling of cache for Parse Server applications.