American Express Interview Question: How would you implement a lim... | Glassdoor

Interview Question

Lead Developer Interview Saint Petersburg, FL

How would you implement a limited capacity cache that can

  be used as a temporary storage with expiry.

Interview Answer

1 Answer


Use a static list of objects and always add new items to the end of the list

Every time an item is accessed from the list, remove it from its current position and add to the end of the list.

Whenever you reach the maximum allowed items in the list please remove the item in the top of the list.

Make sure any operation that adds or removes items from the list places a write lock on the list.

Interview Candidate on Oct 8, 2013

Add Answers or Comments

To comment on this, Sign In or Sign Up.