• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * PriceCache
3 */
4function PriceCache() {
5}
6
7PriceCache.prototype = {
8	getCachedPrice: function(instrumentId) {
9	},
10	setCachedPrice: function(instrumentId, price) {
11	}
12}
13
14/**
15 * PriceFetcher
16 */
17function PriceFetcher() {
18}
19
20PriceFetcher.prototype = {
21	getPriceFromServer: function(instrumentId) {
22	}
23}
24
25
26/**
27 * PriceService
28 */
29function PriceService(priceFetcher, priceCache) {
30	this._priceFetcher = priceFetcher;
31	this._priceCache = priceCache;
32}
33
34PriceService.prototype = {
35	getPrice: function(instrumentId) {
36		var price = this._priceCache.getCachedPrice(instrumentId);
37		if(price==null) {
38			price = this._priceFetcher.getPriceFromServer(instrumentId);
39			this._priceCache.setCachedPrice(instrumentId, price);
40		}
41		return price;
42	}
43}
44