Update cache periodically.

This commit is contained in:
Alexander Zobnin
2016-02-01 17:33:08 +03:00
parent 57f8776451
commit 7c883bd781
3 changed files with 18 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ function (angular, _, utils) {
// Use factory() instead service() for multiple datasources support.
// Each datasource instance must initialize its own cache.
module.factory('ZabbixCachingProxy', function($q) {
module.factory('ZabbixCachingProxy', function($q, $interval) {
function ZabbixCachingProxy(zabbixAPI, ttl) {
this.zabbixAPI = zabbixAPI;
@@ -33,6 +33,9 @@ function (angular, _, utils) {
// Wrap _refresh() method to call it once.
this.refresh = callOnce(p._refresh, this.refreshPromise);
// Update cache periodically
$interval(_.bind(this.refresh, this), this.ttl);
}
var p = ZabbixCachingProxy.prototype;