Two (or more) LRU caches for a Node.js app Here is a caching code of a nodejs / typescript app using lru Cache module from https://www.npmjs.com/package/lru-cache.
For various reason i need to setup separate caches: one for homeCache another one for detailThreadCache... but this is just the beginning I may need to set up more.

This code is working, but how would you refactor it to improve code reuse ? Would you use object oriented paradigm ? If yes how ?

const homeCache = lruCache( 50 )
const detailThreadCache = lruCache( 150 )

export function homeCachedData( key ) {
    return homeCache.get( key )
}

export function homeSetCache( key: string, value, duration: number ) {
    homeCache.set( key, value, duration )
}

export function detailThreadGetCache( key ) {
    return detailThreadCache.get( key )
}

export function detailThreadSetCache( key: string, value, duration: number ) {
    detailThreadCache.set( key, value, duration )
}
As mentioned in the comments, remove the functions. Don't even go into OOP. As to why, they're simply unnecessary wrappers to your cache objects which you can just access directly. detailThreadCache.set is just as verbose as detailThreadSetCache.

Improving code doesn't necessarily mean reuse or encapsulation or a paradigm shift. Often times, the best code... is the one that's never written.