try available cache storages
[pharext/pharext.org] / app / bootstrap / github.php
index 30bd96d88727decc1a97de18e7eafa77396e2925..e0defa7bc5482da1f53c647431470e25e1e43eca 100644 (file)
@@ -17,12 +17,20 @@ $injector->share(Github\API::class)
                                0);
                }
                // FIXME: configure through app.ini
+               try {
+                       $cache = new Github\Storage\Redis("gh-cache");
+               } catch (\Exception $ex) {
+                       try {
+                               $cache = new Github\Storage\Memcache("gh-cache");
+                       } catch (\Exception $ex) {
+                               $cache = null;
+                       }
+               }
                return new Github\API(
                         $config->github
                        ,new Github\Logger($config)
                        ,new Github\Storage\Session("gh-tokens")
-                  #,new Github\Storage\Memcache("gh-cache")
-                       ,new Github\Storage\Redis("gh-cache")
+                       ,$cache
           );
        });