From f12d9adc06fcfbb49d5adad7ee0882b73f52a743 Mon Sep 17 00:00:00 2001 From: "B.J. Rossiter" Date: Tue, 26 Feb 2013 14:42:59 +1100 Subject: [PATCH] Removed memcache --- composer.json | 3 +-- src/DGM/Bootstrap.php | 9 +-------- src/DGM/Service/AverageBudget.php | 14 +++----------- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 41668db..0117f59 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,6 @@ "silex/silex": "1.0.*", "twig/twig": "1.*", "sendgrid/sendgrid-php": "dev-master", - "mheap/Silex-Memcache": "*", "andylockran/createsend-php": "*", "monolog/monolog": "1.2.*" }, @@ -14,4 +13,4 @@ "Sly": "vendor/sly/url-shortener-bundle/" } } -} \ No newline at end of file +} diff --git a/src/DGM/Bootstrap.php b/src/DGM/Bootstrap.php index 646be93..ff20a51 100644 --- a/src/DGM/Bootstrap.php +++ b/src/DGM/Bootstrap.php @@ -68,13 +68,6 @@ public function register(Application $app) 'monolog.appname' => 'budget2012' ]); - $app->register(new \SilexMemcache\MemcacheExtension(), [ - 'memcache.library' => 'memcached', - 'servers' => [ - ['localhost', '11211'] - ] - ]); - $app->register(new \Silex\Provider\TwigServiceProvider(), [ 'twig.path' => __DIR__.'/../../templates', ]); @@ -101,7 +94,7 @@ public function register(Application $app) public function boot(Application $app) { $app['averageBudget'] = $app->share(function(Application $app) { - return (new \DGM\Service\AverageBudget($app['budgets'], $app['memcache']))->getAverageBudget(); + return (new \DGM\Service\AverageBudget($app['budgets']))->getAverageBudget(); }); } diff --git a/src/DGM/Service/AverageBudget.php b/src/DGM/Service/AverageBudget.php index 9b0186c..9a6ef2c 100644 --- a/src/DGM/Service/AverageBudget.php +++ b/src/DGM/Service/AverageBudget.php @@ -8,27 +8,19 @@ class AverageBudget { private $budgets; - private $memcached; const EXPIRES = 600; // 10 minutes const CACHE_KEY = 'averageBudget'; - public function __construct(Budgets $budgets, \Memcached $memcached) + public function __construct(Budgets $budgets) { $this->budgets = $budgets; - $this->memcached = $memcached; } public function getAverageBudget() { - $averageBudget = $this->memcached->get(self::CACHE_KEY); - - if ($this->memcached->getResultCode() == \Memcached::RES_NOTFOUND) { - $averageBudget = $this->budgets->getAverageBudget(); - $this->memcached->set(self::CACHE_KEY, $averageBudget, self::EXPIRES); - } - + $averageBudget = $this->budgets->getAverageBudget(); return $averageBudget; } -} \ No newline at end of file +}