GenericCache

interface GenericCache<K, V>(source)

Copyright 2020 kezhenxu94

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A Generic K,V GenericCache defines the basic operations to a cache.

Inheritors

Properties

Link copied to clipboard
abstract val size: Int

The number of the items that are currently cached.

Functions

Link copied to clipboard
abstract fun clear()

Remove all the items in the cache.

Link copied to clipboard
abstract operator fun get(key: K): V?

Get the cached value of a given key, or null if it's not cached or evicted.

Link copied to clipboard
abstract fun remove(key: K): V?

Remove the value of the key from the cache, and return the removed value, or null if it's not cached at all.

Link copied to clipboard
abstract operator fun set(key: K, value: V)

Cache a value with a given key