-
Notifications
You must be signed in to change notification settings - Fork 6
CachedConfigProvider
Javier Diaz edited this page Jul 30, 2018
·
3 revisions
Caching is necessary most of the time! When in doubt, cache!
How Cfg4k works is that it will load the file in memory (Loader) and everything will be a String (or null in some special cases) but after that it needs to be converted into the correct type when you bind
or get
a property. This bind
/get
will convert the loaded string into the real type that you are asking to and if the provider is not the type CachedConfigProvider
, it will convert it everytime you ask for the property.
When you add the caching layer, that conversion will only happen the first time and after each reload (a reload will invalidate the cache). So for an increased performance it is recommended to cache your provider.
val nonCached = ProxyConfigProvider(loader)
val cached = CachedConfigProvider(ProxyConfigProvider(loader))
val otherCached = ProxyConfigProvider(loader).cache()