Generic in-node caching library with memoization support