4 function PriceCache() {
7 PriceCache.prototype = {
8 getCachedPrice: function(instrumentId) {
10 setCachedPrice: function(instrumentId, price) {
17 function PriceFetcher() {
20 PriceFetcher.prototype = {
21 getPriceFromServer: function(instrumentId) {
29 function PriceService(priceFetcher, priceCache) {
30 this._priceFetcher = priceFetcher;
31 this._priceCache = priceCache;
34 PriceService.prototype = {
35 getPrice: function(instrumentId) {
36 var price = this._priceCache.getCachedPrice(instrumentId);
38 price = this._priceFetcher.getPriceFromServer(instrumentId);
39 this._priceCache.setCachedPrice(instrumentId, price);