UNPKG

search-destination-cache

Version:

Search destinations by name, address, point of interest or coordinates. Using Redis DB for caching.

32 lines (24 loc) 689 B
var _ = require('underscore'); var Search = require('./search'); var Updater = require('./update'); /** * Wrapper for update search result in cache asynchronously */ function UpdateWrapper () {} UpdateWrapper.prototype.getUpdater = function () { if (!_.isObject(this.updater)) { this.updater = new Updater(); } return this.updater; } UpdateWrapper.prototype.activateCacheUpdater = function () { var fn = function (eventChannel, key) { var search = new Search(); search.refresh(key); } this.getUpdater().activate(fn); } UpdateWrapper.prototype.deactivateCacheUpdater = function () { this.getUpdater().deactivate(); } module.exports = new UpdateWrapper();