Skip to content
jbaicoianu edited this page May 31, 2011 · 5 revisions

The DataManager provides an unified data and caching layer which allows access to many different types of data sources through a single consistent interface. Any data source which can implement basic record-based CRUD (Create/Read/Update/Delete) operations can be supported via a wrapper class. Each source can be given its own caching policy (specified in the ConfigManager or on a per-query basis), and the DataManager will automatically and transparently cache lookups while ensuring consistency with updates and deletes.

Supported Sources

  • db (sqlite, MySQL, PostgreSQL, etc. via PDO)
  • cassandra (currently, support for either 0.6 or 0.7, exclusively)
  • rest (generic HTTP-based API support, XML/JSON, simple or OAuth)
  • xmlrpc
  • memcache
  • apc

Supported Caches

Interface

(NOTE - this temporarily differs slightly from what's in the code, this is my attempt to formalize everything while also cleaning up some of the more confusing parts of using the system as it stands today. When the code has been sufficiently refactored, this notice will be removed.)

  • DataManager::fetch($source, $id[, $queryargs]*);*
    Fetch a row or multiple rows from the source by id. Optionally, $args can provide source-specific arguments which can be used to filter or limit the returned results, eg:

    $user = DataManager::fetch("db.userdata.user", "[email protected]");
    $facebookfriends = DataManager::fetch("rest.facebook", "/{$user->facebookid}/friends");

  • DataManager::insert($source, $id, $value);
    Insert a row or multiple rows of data.

  • DataManager::update($source, $id, $value);

  • DataManager::delete($source, $id[, $queryargs]*);*

  • DataManager::count($source, $id[, $queryargs]*);*

  • DataManager::create($source, $id, $schema);

  • DataManager::drop($source, $id);

Query Logger

The DataManager automatically keeps some basic stats on which queries were called to render the current page, and can either output this to a file or send it to a MessageServer for collection and processing.

{"reqid":1682477493,"id":"db.config.version.ALL.live","type":"query","time":0.00393605232,"cached":true} {"reqid":2116538817,"id":"cassandra.userdata.usersession#194e25ffccbde15f8c089305bc336fb9","type":"fetch","time":0.0737080574,"cached":false}