   def handle_call({:get, key}, _from, state) do
     value = case Map.fetch(state, key) do
       :error -> {:not_found}
-      {:ok, result} -> if now() >= result.expires_at do
+      {:ok, result} -> if Entry.expired?(result) do
         {:not_found}
       else
         {:found, result.value}


  ## Client API

  defmodule Entry do
    @moduledoc """
    `Cache.Entry` struct capable of holding any value along with expiration timestamp.
    """
    defstruct [:value, :expires_at]
  end

  @doc """

  Puts the key + value in the state map along with it's expiration timestamp.
  """
  def handle_call({:set, key, value, expires_in}, _from, state) do
    entry = Entry.build(value, expires_in)
    state = Map.put(state, key, entry)

    {:reply, value, state}
  end
end
