net.markenwerk:utils-lrucache

A simple LRU cache for Java

Лицензия

Лицензия

Категории

Категории

Сеть
Группа

Группа

net.markenwerk
Идентификатор

Идентификатор

utils-lrucache
Последняя версия

Последняя версия

1.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

net.markenwerk:utils-lrucache
A simple LRU cache for Java
Ссылка на сайт

Ссылка на сайт

https://github.com/markenwerk/java-utils-lrucache
Организация-разработчик

Организация-разработчик

Markenwerk – Gesellschaft für markenbildende Maßnahmen mbH
Система контроля версий

Система контроля версий

https://github.com/markenwerk/java-utils-lrucache

Скачать utils-lrucache

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/net.markenwerk/utils-lrucache/ -->
<dependency>
    <groupId>net.markenwerk</groupId>
    <artifactId>utils-lrucache</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/net.markenwerk/utils-lrucache/
implementation 'net.markenwerk:utils-lrucache:1.0.1'
// https://jarcasting.com/artifacts/net.markenwerk/utils-lrucache/
implementation ("net.markenwerk:utils-lrucache:1.0.1")
'net.markenwerk:utils-lrucache:jar:1.0.1'
<dependency org="net.markenwerk" name="utils-lrucache" rev="1.0.1">
  <artifact name="utils-lrucache" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.markenwerk', module='utils-lrucache', version='1.0.1')
)
libraryDependencies += "net.markenwerk" % "utils-lrucache" % "1.0.1"
[net.markenwerk/utils-lrucache "1.0.1"]

Зависимости

test (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.

A simple LRU cache for Java

Build Status Coverage Status Dependency Status Maven Central Issues MIT License

This library provides a simple LRU cache based on a linked hash map.

Overview

This library is hosted in the Maven Central Repository. You can use it with the following coordinates:

<dependency>
	<groupId>net.markenwerk</groupId>
	<artifactId>utils-lrucache</artifactId>
	<version>1.0.1</version>
</dependency>

Consult the usage description and Javadoc for further information.

Motivation

As every Java programmer should know, it is possible to create a simple LRU cache from a LinkedHashMap with a few lines of code. The goal of this library is to provide a ready made LRU cache, so that is isn't necessary to reproduce these few lines of code every time and have an appropriately named class.

Usage

LRU caching

This library provides the simple LruCache which is a LinkedHashMap that is configured to hold it's entries in access order and evicts the least recently accessed entry, if the configured cache size is exceeded.

// the desired cache size
int cacheSize = ...

// a map that never holds more than cacheSize elements
Map<String, Object> cache = new LruCache<>(cacheSize);

Listening to eviction events

A LruCache can be created with a LruCacheListener that gets notified, when an entry is evicted from the LruCache.

// the desired cache size
int cacheSize = ...

// a map that never holds more than cacheSize elements
Map<String, Object> cache = new LruCache<>(
	cacheSize,
	entry -> System.out.println(entry.getKey() + " got evicted")
);
net.markenwerk

Markenwerk

Версии библиотеки

Версия
1.0.1
1.0.0