<p>Write a class that allows getting and setting key-value pairs, however a <strong>time until expiration</strong> is associated with each key.</p>
<p>The class has three public methods:</p>
<p><code>set(key, value, duration)</code>: accepts an integer <code>key</code>, an integer <code>value</code>, and a <code>duration</code> in milliseconds. Once the <code>duration</code> has elapsed, the key should be inaccessible. The method should return <code>true</code> if the same un-expired key already exists and <code>false</code> otherwise. Both the value and duration should be overwritten if the key already exists.</p>
<p><code>get(key)</code>: if an un-expired key exists, it should return the associated value. Otherwise it should return <code>-1</code>.</p>
<p><code>count()</code>: returns the count of un-expired keys.</p>
At t=0, a key-value pair (1: 42) is added with a time limit of 50ms. The value doesn't exist so false is returned.
At t=40, a key-value pair (1: 50) is added with a time limit of 100ms. A non-expired value already existed so true is returned and the old value was overwritten.
At t=50, get(1) is called which returned 50.
At t=120, get(1) is called which returned 50.
At t=140, key=1 expires.
At t=200, get(1) is called but the cache is empty so -1 is returned.
At t=250, count() returns 0 because the cache is empty.