set method
void
set(
- K key,
- V value
Implementation
void set(K key, V value) {
if (_cache.containsKey(key)) {
_cache.remove(key);
}
else if (_cache.length >= maxSize) {
// Remove the least recently used (first) entry
_cache.remove(_cache.keys.first);
}
_cache[key] = value;
}