Pregunta de entrevista de Playtech

Coding assignment: Implement generic structure EvictionMap that acts as key-value map with following time-based eviction policy: expire entry after the specified duration has passed since the entry was created, or the most recent replacement of the value. Specify duration as EvictionMap constructor parameter. Methods: a) Creates value with specified key in this map. If the map previously contained a value associated with key, the old value is replaced by new value: public void put(K key, V value) b) Returns the value associated with key in this map or null if no mapping exists public V get(K key) Provide at least one unit test that verifies time based eviction. Example test case: 1) Initiate map with duration of 10 seconds 2) Use "put" to insert one key-value item into the map 3) Use "get" to retrieve it back immediately - value should be still there 4) wait 11 seconds 5) Use "get" to retrieve by same key again - it should return null as entry has been evicted internally by map (cause eviction duration has already passed for the entry) Things to consider when implementing: - thread safety (depends on if/how you rely on threading) - avoiding acquiring too much system resources Additionally: - make sure to provide unit tests - add readme file to the project explaining your solution design and major decisions - pay attention to coding style, formatting and general design - deliver solution as zipped Maven or Gradle project, code written in Java. It should be easy to just import into any Java IDE, build and run tests! - include only sources files and project files, no binary files Please note that your eviction map could be used by long running applications and in various ways. You can choose optimal generic implementation strategy for your solution. As a bonus explain briefly other possible implementation strategies that maybe be more optimal for some extreme use cases. For example users may want to use your map with very large number of entries (above 100k) and/or long duration periods (in hours or days).