Amazon Interview Question

design api for cache management

Interview Answers

Anonymous

Dec 24, 2011

looking for what kind of function u will expose with exceptions etc...

Anonymous

Jan 3, 2012

What was the answer for this? My answer would be we should apply adapter design pattern (or bridge) into this question since we could cache data using many storage engine (file, memcache, db).

Anonymous

Oct 21, 2012

From answer is Cache with Proxy pattern package xyz; public interface Data{ public String getData(); } package xyz; class RealData implements Data{ private String data; RealData(String data){ this.data = data; } public String getData(){ return data; } } package xyz; public class CacheDataProxy implements Data{ private String data = null; private RealData realData; public CacheDataProxy(){ realData = new RealData(); } public String getData(){ if(data == null){ data = realData.getData(); } return data; } }