firefly icon indicating copy to clipboard operation
firefly copied to clipboard

Centralized cache manager

Open awrichar opened this issue 2 years ago • 1 comments

FireFly has lots of isolated usage of ccache in many different managers. See here and here for examples.

It would make sense to consolidate this under a new, centralized Cache Manager component. It should be created under internal/cache and should follow the pattern set by other managers, particularly the Metrics Manager. It should be a singleton like Metrics Manager, and should be initialized early by Namespace Manager (the root manager). It can then be passed to all other plugins and managers that require it.

The interface can be quite simple, likely something like Get(category string, key string) and Set(category string, key string).

As part of this, it would also make sense to consolidate the config options under a top-level cache key. The blockchain cache is already following this pattern, but other cache configuration is scattered at various levels throughout the config tree. The old keys should be deprecated in favor of new ones that are grouped together under cache.

awrichar avatar Aug 09 '22 16:08 awrichar

Two items with TODOs that aren't yet cached: https://github.com/hyperledger/firefly/blob/bd63308c8cc855b4859ffc114d4ef6fcdcd7f42e/internal/events/tokens_transferred.go#L72 https://github.com/hyperledger/firefly/blob/bd63308c8cc855b4859ffc114d4ef6fcdcd7f42e/internal/events/tokens_approved.go#L72

Might as well add token pools to the cache after centralizing it.

awrichar avatar Aug 09 '22 17:08 awrichar