Implements a key-based cache with LRU or TTL policy