View Source ConfigCat.CachePolicy (ConfigCat v4.0.2)
Represents the polling mode used by ConfigCat.
The ConfigCat SDK supports 3 different polling mechanisms to acquire the setting values from ConfigCat. After the latest setting values are downloaded, they are stored in the internal cache and all requests are served from there.
With the following polling modes, you can customize the SDK to best fit to your application's lifecycle.
Auto polling (default)
The ConfigCat SDK downloads the latest values and stores them automatically on a regular schedule.
See auto/1
below for details.
Lazy loading
When calling any of the public API functions (like get_value()
),
the ConfigCat SDK downloads the latest setting values if they are
not present or have expired. In this case the function will wait
until the settings have been fetched before returning.
See lazy/1
below for details.
Manual polling
Manual polling gives you full control over when the setting
values are downloaded. ConfigCat SDK will not update them
automatically. Calling ConfigCat.force_refresh/1
is your
application's responsibility.
See manual/0
below for details.
Summary
Types
Options for auto-polling mode.
Options for lazy-polling mode.
Callback to call when configuration changes.
The polling mode
Types
@type auto_options() :: [ max_init_wait_time_seconds: non_neg_integer(), poll_interval_seconds: pos_integer() ]
Options for auto-polling mode.
@type lazy_options() :: [{:cache_refresh_interval_seconds, non_neg_integer()}]
Options for lazy-polling mode.
@type on_changed_callback() :: (-> :ok)
Callback to call when configuration changes.
@opaque t()
The polling mode
Functions
@spec auto(auto_options()) :: t()
Auto-polling mode.
The ConfigCat SDK downloads the latest values and stores them automatically on a regular schedule.
Use the max_init_wait_time_seconds
option to set the maximum waiting time
between initialization and the first config acquisition. Defaults to 5 seconds
if not specified.
ConfigCat.CachePolicy.auto(max_init_wait_time_seconds: 5)
Use the poll_interval_seconds
option to change the
polling interval. Defaults to 60 seconds if not specified.
ConfigCat.CachePolicy.auto(poll_interval_seconds: 60)
@spec lazy(lazy_options()) :: t()
Lazy polling mode.
When calling any of the public API functions (like get_value()
),
the ConfigCat SDK downloads the latest setting values if they are
not present or have expired. In this case the function will wait
until the settings have been fetched before returning.
Use the required cache_refresh_interval_seconds
option to set the cache
lifetime.
ConfigCat.CachePolicy.lazy(cache_refresh_interval_seconds: 300)
@spec manual() :: t()
Manual polling mode.
Manual polling gives you full control over when the setting
values are downloaded. ConfigCat SDK will not update them
automatically. Calling ConfigCat.force_refresh/1
is your
application's responsibility.
ConfigCat.CachePolicy.manual()