Is it possible to override server side javascript from my plugin?
-
I want to update how NodeBB's caching works for my particular usecase.
To be able to do that, I need to update the get and set methods for:
src/cache/ttl
andsrc/cache/lru
This is of course possible by directly editing these files. But is there some way to override them from my own plugin?
-
Maybe you can override the set/get methods in the lru-cache module directly in your plugin. Try something like the below at the top of your plugin code.
const { LRUCache } = require.main.require('lru-cache'); const origSet = LRUCache.prototype.set; LRUCache.prototype.set = function (...args) { console.log('custom lru set'); return origSet.apply(this, args); }
Copyright © 2024 NodeBB | Contributors