App-Config-Chronicle
view release on metacpan or search on metacpan
App::Config::Chronicle - An OO configuration module which can be
changed and stored into chronicle database.
SYNOPSIS
my $app_config = App::Config::Chronicle->new;
DESCRIPTION
This module parses configuration files and provides interface to access
configuration information.
FILE FORMAT
The configuration file is a YAML file. Here is an example:
system:
description: "Various parameters determining core application functionality"
isa: section
contains:
email:
description: "Dummy email address"
isa: Str
default: "dummy@mail.com"
global: 1
refresh:
description: "System refresh rate"
isa: Num
default: 10
global: 1
admins:
description: "Are we on Production?"
isa: ArrayRef
default: []
Every attribute is very intuitive. If an item is global, you can change
its value and the value will be stored into chronicle database by
calling the method save_dynamic.
SUBROUTINES/METHODS (LEGACY)
REDIS_HISTORY_TTL
The maximum length of time (in seconds) that a cached history entry
will stay in Redis.
definition_yml
The YAML file that store the configuration
chronicle_reader
The chronicle store that configurations can be fetch from it. It should
be an instance of Data::Chronicle::Reader. But user is free to
implement any storage backend he wants if it is implemented with a
'get' method.
chronicle_writer
The chronicle store that updated configurations can be stored into it.
It should be an instance of Data::Chronicle::Writer. But user is free
to implement any storage backend he wants if it is implemented with a
'set' method.
chronicle_subscriber
The chronicle connection that can notify via callbacks when particular
configuration items have a new value set. It should be an instance of
Data::Chronicle::Subscriber.
refresh_interval
How much time (in seconds) should pass between check_for_update
invocations until it actually will do (a bit heavy) lookup for settings
in redis.
Default value is 10 seconds
check_for_update
check and load updated settings from chronicle db
Checks at most every refresh_interval unless forced with a truthy first
argument
save_dynamic
Save dynamic settings into chronicle db
current_revision
Loads setting from chronicle reader and returns the last revision
It is more likely that you want "loaded_revision" in regular use
loaded_revision
Returns the revision loaded and served by this instance
This may not reflect the latest stored version in the Chronicle
persistence. However, it is the revision of the data which will be
returned when querying this instance
SUBROUTINES/METHODS ######################################################
###### Start new API ######################################################
local_caching
If local_caching is set to the true then key-value pairs stored in
Redis will be cached locally.
Calling update_cache will update the local cache with any changes from
Redis. refresh_interval defines (in seconds) the minimum time between
seqequent updates.
Calls to get on this object will only ever access the cache. Calls to
set on this object will immediately update the values in the local
cache and Redis.
update_cache
Loads latest values from data chronicle into local cache. Calls to this
method are rate-limited by refresh_interval.
global_revision
Returns the global revision version of the config chronicle. This will
correspond to the last time any of values were changed.
set
Takes a hashref of key->value pairs and atomically sets them in config
chronicle
Example: set({key1 => 'value1', key2 => 'value2', key3 =>
'value3',...});
get
Takes either - an arrayref of keys, gets them atomically, and returns a
hashref of key->values, including the global_revision under the key
( run in 2.294 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )