After my previous blog post, i have been working on making progress on working model w.r.t NoSQL and config. Starting with civicrm cache was a good idea. Keeping in head NoSQL, new config system and what Eileen has already done with settings, here is what i planned and accomplished :
Placed cache and cache-type (mongodb) settings file on disk with default values
Sticking to plans in previous post, and eileen's work on richer metadata, created two files in settings directory of civicrm. Richer metadata does help in creating web configuration forms without any extra coding for the config-items, and i was able to use it for building the new simple config UI.
deepak@bfc:civicrm$ ls settings .... system.cache.php system.cache.mongodb.php .... deepak@bfc:settings$ cat system.cache.php return array( 'class' => array( 'group_name' => 'system.cache', 'group' => 'cache', .... 'default' => 'ArrayCache', 'title' => 'Cache Class', .... 'help_text' => 'default is mongodb if not set', ), ); deepak@bfc:settings$ cat system.cache.mongodb.php return array( 'host' => array( 'group_name' => 'system.cache.mongodb', 'group' => 'cache', 'name' => 'host', 'default' => 'localhost', .... ), 'db' => array( 'group_name' => 'system.cache.mongodb', 'group' => 'cache', 'name' => 'db', 'default' => 'civicrm', 'title' => 'Database', .... ), ....
Default setting is read and stored in db - civicrm_settings table
During initialization or when a setting is asked for, setting table is loaded with values from config files - system.cache and system.cache.mongodb. To whats already available in civicrm v4.3, it also allows users to override default values.
Every time a setting is stored in db, a new config file is created on disk
When a setting is altered / saved in setting table, a new file with same values is also written to disk in .../files/civicrm/ConfigAndLog/ directory. The file structure is exactly same as that of residing in civicrm/settings directory with an additional attribute 'value' holding the latest value for the config item.
deepak@bfc:~$ ls /var/www/mongo.loc/sites/default/files/civicrm/ConfigAndLog/
CiviCRM.db145e70b362f94fbfe4c5a865ca538c.log
system.cache.mongodb.php
system.cache.php
Provide a UI to allow user to tweak default setting, reset to default and restore settings from files on disk
Needed a single interface to update cache settings, reset to default values at any point of time and be able to restore settings from files in ConfigAndLog directory also helping in migration.
Make cache code pickup cache settings and work with cache-type (mongodb here)
For me plugging in the mongodb wasn't so difficult, as it was to make caching work with new config. The cache now picks up settings from db to figure out the configured cache. And how mongodb works as a cache is driven by CRM/Utils/Cache/Mongodb.php file. For now it only works for mongodb but wouldn't be hard to provide support of other already supported caches per new config style.

The implementation serves as a prototype for new config and mongodb as cache.
The code is all available on github - https://github.com/deepak-srivastava/nosql-config.