American Express

  www.americanexpress.com
  www.americanexpress.com
Work in HR? Unlock Free Profile

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.
Tags:
algorithm
Answer

Interview Answer

1 Answer

0

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 question, Sign In with Facebook or Sign Up