shen2 / hilo
Hierarchy Loader
dev-master
2016-03-29 15:58 UTC
Requires
- php: >=5.5.9
- shen2/easy-redis: dev-master
This package is auto-updated.
Last update: 2024-12-23 19:47:33 UTC
README
Hierarchical Loader.
Installation
composer require shen2/hilo
Usage
class PromotionAdapter extends \Hilo\CustomAdapter { use \Hilo\JsonSerializer; protected $_cacheNamespace = 'promotion'; protected $_ttl = 3600; public function fetch($key) { $ads = \Ad::select() ->where('find_in_set(?, positions)', $key) ->order('ad_id desc') ->fetchAll(); return $ads; } } $redisConfig = [...]; $redisManager = new RedisManager($redisConfig); $adapter = new PromotionAdapter($redisManager); $container = new Hilo\Container($adapter); $container->get('key'); $container->getMulti(['key1', 'key2']);