hergot / databroker
data broker
Requires
- php: >=5.4
Requires (Dev)
- mikey179/vfsstream: >=1.1.0
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2020-01-06 05:33:34 UTC
README
##Purpose
Databroker helps application to be more elastic e.g. you can easily turn on/off caching for various data fetch (database queries, rest and soap calls, file fetch, ...). It implements plugin architecture so it is easy to extend databroker with additional functionality (cache, monitor, ...).
##Use Cases
- If you want monitor all database queries, rest calls, ...
- If you want easily turn on cache for select queries, calls, ...
- If you want easily switch calls (e.g. instead of database query use rest call) without changing application code
- If you want non reliably remote call do reliably call (i.e. use fail strategy)
##Installation
Clone repository
$ git clone git://github.com/hergot/databroker.git && cd databroker
Get composer
$ curl -s https://getcomposer.org/installer | php
Run composer
$ ./composer.phar install --dev
Create symbolic link for phpunit
$ ln -nfs ./vendor/phpunit/phpunit/composer/bin/phpunit ./phpunit
##Run unit tests
$ ./phpunit -c .
###Run code coverage with unit tests
$ ./phpunit --coverage-html <folder path e.g. /tmp/coverage> -c .
###Notes
####APC
You have to enable apc for cli - apc.enable_cli=1 in php.ini file or run phpunit with --exclude-group apc
$ ./phpunit --exclude-group apc -c .
##Plugins
###Cache plugin
This plugin cache data fetch into cache backends (APC, file, ...). This plugin have to be configured via setup method - this method expects name or mask of data fetch call. Mask can contain asterix * as wild character.
####Configuration example
$cachePlugin->setup('*') ->setCacheable(true) ->setLifeTime(60) ->setRefreshTime(10) ->setBackend($cacheBackend);
This means to cache all (* - mask) data fetch for 60 seconds. Every 10 seconds refresh content in cache backend. Use $cacheBackend as cache backend.