description | Java memoization library |
homepage URL | https://github.com/sebhoss/memoization.java |
repository URL | https://github.com/sebhoss/memoization.java.git |
owner | repoorcz@shoss.de |
last change | Thu, 8 Feb 2024 01:42:51 +0000 (8 02:42 +0100) |
last refresh | Thu, 21 Nov 2024 07:41:31 +0000 (21 08:41 +0100) |
mirror URL | git://repo.or.cz/memoization.java.git |
https://repo.or.cz/memoization.java.git | |
ssh://git@repo.or.cz/memoization.java.git | |
bundle info | memoization.java.git downloadable bundles |
content tags |
Java memoization library - trade space for time
Consumer
, Function
, Predicate
, Supplier
, and moreConsumer0..16
and Function0..16
Fn0..8
Action
, Cancellable
, and moreConcurrentMap
.Memoize any of the supported types by using the static factory methods supplied by:
Memoize
if you want to memoize JDK interfaces.MemoizeJool
if you want to memoize jOOL interfaces.MemoizeLambda
if you want to memoize lambda interfaces.MemoizeRx
if you want to memoize RxJava interfaces.wtf.metio.memoization.jdk.Memoize;
wtf.metio.memoization.jool.MemoizeJool;
wtf.metio.memoization.lambda.MemoizeLambda;
wtf.metio.memoization.rxjava.MemoizeRx;
Function<INPUT, OUTPUT> function = ...;
Function<INPUT, OUTPUT> memoizedFunction = Memoize.function(function);
Supplier<OUTPUT> supplier = ...;
Supplier<OUTPUT> memoizedSupplier = MemoizeRx.supplier(supplier);
Function3<T1, T2, T3, OUTPUT> function = ...;
Function3<T1, T2, T3, OUTPUT> memoizedFunction = MemoizeJool.function3(function);
Fn4<T1, T2, T3, T4, OUTPUT> function = ...;
Fn4<T1, T2, T3, T4, OUTPUT> memoizedFunction = MemoizeLambda.fn4(function);
wtf.metio.memoization.jdk.Memoize;
wtf.metio.memoization.jool.MemoizeJool;
wtf.metio.memoization.lambda.MemoizeLambda;
wtf.metio.memoization.rxjava.MemoizeRx;
Function<INPUT, OUTPUT> function = ...;
Function<INPUT, KEY> keyFunction = ...;
Function<INPUT, OUTPUT> memoizedFunction = Memoize.function(function, keyFunction);
Supplier<OUTPUT> supplier = ...;
Supplier<KEY> keySupplier = ...;
Supplier<OUTPUT> memoizedSupplier = MemoizeRx.supplier(supplier, keySupplier);
Function3<T1, T2, T3, OUTPUT> function = ...;
Function3<T1, T2, T3, KEY> keyFunction = ...;
Function3<T1, T2, T3, OUTPUT> memoizedFunction = MemoizeJool.function3(function, keyFunction);
Fn4<T1, T2, T3, T4, OUTPUT> function = ...;
Fn4<T1, T2, T3, T4, KEY> keyFunction = ...;
Fn4<T1, T2, T3, T4, OUTPUT> memoizedFunction = MemoizeLambda.fn4(function, keyFunction);
wtf.metio.memoization.jdk.Memoize;
wtf.metio.memoization.jool.MemoizeJool;
wtf.metio.memoization.lambda.MemoizeLambda;
wtf.metio.memoization.rxjava.MemoizeRx;
// memoize in cache2k cache
Function<INPUT, OUTPUT> function = ...;
Cache<INPUT, OUTPUT> cache = ...; // org.cache2k.Cache
Function<INPUT, OUTPUT> memoizedFunction = Memoize.function(function, cache.asMap());
// memoize in Caffeine cache
Supplier<OUTPUT> supplier = ...;
Cache<Integer, OUTPUT> cache = ...; // com.github.benmanes.caffeine.cache.Cache
Supplier<OUTPUT> memoizedSupplier = MemoizeRx.supplier(supplier, cache.asMap());
// memoize in Guava cache
Function3<T1, T2, T3, OUTPUT> function = ...;
Cache<Integer, OUTPUT> cache = ...; // com.google.common.cache.Cache
Function3<T1, T2, T3, OUTPUT> memoizedFunction = MemoizeJool.function3(function, cache.asMap());
// memoize in ConcurrentMap
Fn4<T1, T2, T3, T4, OUTPUT> function = ...;
Map<Integer, OUTPUT> cache = ...;
Fn4<T1, T2, T3, T4, OUTPUT> memoizedFunction = MemoizeLambda.fn4(function, cache);
wtf.metio.memoization.jdk.Memoize;
wtf.metio.memoization.jool.MemoizeJool;
wtf.metio.memoization.lambda.MemoizeLambda;
wtf.metio.memoization.rxjava.MemoizeRx;
// memoize in cache2k cache
Function<INPUT, OUTPUT> function = ...;
Function<INPUT, KEY> keyFunction = ...;
Cache<KEY, OUTPUT> cache = ...; // org.cache2k.Cache
Function<INPUT, OUTPUT> memoizedFunction = Memoize.function(function, keyFunction, cache.asMap());
// memoize in Caffeine cache
Supplier<OUTPUT> supplier = ...;
Supplier<KEY> keySupplier = ...;
Cache<KEY, OUTPUT> cache = ...; // com.github.benmanes.caffeine.cache.Cache
Supplier<OUTPUT> memoizedSupplier = MemoizeRx.supplier(supplier, keySupplier, cache.asMap());
// memoize in Guava cache
Function3<T1, T2, T3, OUTPUT> function = ...;
Function3<T1, T2, T3, KEY> keyFunction = ...;
Cache<KEY, OUTPUT> cache = ...; // com.google.common.cache.Cache
Function3<T1, T2, T3, OUTPUT> memoizedFunction = MemoizeJool.function3(function, keyFunction, cache.asMap());
// memoize in ConcurrentMap
Fn4<T1, T2, T3, T4, OUTPUT> function = ...;
Fn4<T1, T2, T3, T4, KEY> keyFunction = ...;
Map<KEY, OUTPUT> cache = ...;
Fn4<T1, T2, T3, T4, OUTPUT> memoizedFunction = MemoizeLambda.fn4(function, keyFunction, cache);
Note that the static factory methods do accept any Map
, however they copy the entries in the map to a new ConcurrentHashMap
in case the provided Map
is not a ConcurrentMap
. This is done in order to ensure atomic computeIfAbsent
behavior.
In order to use this project, declare the following dependencies in your project:
<dependencies>
<!-- support for JDK interfaces -->
<dependency>
<groupId>wtf.metio.memoization</groupId>
<artifactId>memoization-jdk</artifactId>
<version>${version.memoization}</version>
</dependency>
<!-- support for JDK interfaces -->
<!-- support for jOOL interfaces -->
<dependency>
<groupId>wtf.metio.memoization</groupId>
<artifactId>memoization-jool</artifactId>
<version>${version.memoization}</version>
</dependency>
<!-- support for jOOL interfaces -->
<!-- support for lambda interfaces -->
<dependency>
<groupId>wtf.metio.memoization</groupId>
<artifactId>memoization-lambda</artifactId>
<version>${version.memoization}</version>
</dependency>
<!-- support for lambda interfaces -->
<!-- support for RxJava interfaces -->
<dependency>
<groupId>wtf.metio.memoization</groupId>
<artifactId>memoization-rxjava</artifactId>
<version>${version.memoization}</version>
</dependency>
<!-- support for RxJava interfaces -->
</dependencies>
Replace ${version.memoization}
with the latest release.
@Cacheable
@Memoize
(memoize f)
@Memoized
memoize
Memoize
@Cacheable
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
10 months ago | 2024.1.8 | commitlog | ||
11 months ago | 2023.12.12 | commitlog | ||
12 months ago | 2023.11.14 | commitlog | ||
13 months ago | 2023.10.10 | commitlog | ||
14 months ago | 2023.9.12 | commitlog | ||
15 months ago | 2023.8.8 | commitlog | ||
16 months ago | 2023.7.11 | commitlog | ||
17 months ago | 2023.6.13 | commitlog | ||
18 months ago | 2023.5.9 | commitlog | ||
19 months ago | 2023.4.11 | commitlog | ||
20 months ago | 2023.3.14 | commitlog | ||
21 months ago | 2023.2.14 | commitlog | ||
22 months ago | 2023.1.10 | commitlog | ||
23 months ago | 2022.12.13 | commitlog | ||
23 months ago | 2022.12.6 | commitlog | ||
2 years ago | 2022.11.22 | commitlog | ||
... |
9 months ago | main | logtree |