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