You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Memoize calls to `Consumer`, `Function`, `Predicate`, `Supplier` and other functional interfaces in `java.util.function`
13
-
* Cache values using [Caffeine](https://github.com/ben-manes/caffeine), [Guava](https://github.com/google/guava/wiki/CachesExplained), [cache2k](https://cache2k.org/), or any [`ConcurrentMap`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/ConcurrentMap.html).
14
-
* Customize caches and the cache keys
12
+
* Memoize calls to JDK interfaces like `Consumer`, `Function`, `Predicate`, `Supplier`, and more
13
+
* Memoize calls to [jOOL](https://github.com/jOOQ/jOOL) interfaces like `Consumer0..16` and `Function0..16`
14
+
* Use custom caches like [Caffeine](https://github.com/ben-manes/caffeine), [Guava](https://github.com/google/guava/wiki/CachesExplained), [cache2k](https://cache2k.org/), or any other [`ConcurrentMap`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/ConcurrentMap.html).
15
+
* Use custom cache keys for fine-tuning
15
16
16
17
## Usage
17
18
18
19
Memoize any of the supported types by using the static factory methods supplied by:
19
20
20
-
*`Cache2kMemoize` if you want to use [cache2k](https://cache2k.org/) caches.
21
-
*`CaffeineMemoize` if you want to use [Caffeine](https://github.com/ben-manes/caffeine) caches.
22
-
*`GuavaMemoize` if you want to use [Guava](https://github.com/google/guava/wiki/CachesExplained) caches.
23
-
*`MapMemoize` if you want to use any [`ConcurrentMap`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/ConcurrentMap.html) as cache.
21
+
*`Memoize` if you want to memoize JDK interfaces.
22
+
*`MemoizeJool` if you want to memoize jOOL interfaces.
Note that `MapMemoize` does accept any `Map`, however copies the entries in the map to a new `ConcurrentHashMap` in case the provided `Map` is not a `ConcurrentMap` as well. This is done in order to ensure atomic `computeIfAbsent` behavior.
124
+
Note that `Memoize` and `MemoizeJool` 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.
142
125
143
126
## Integration
144
127
145
128
In order to use this project, declare the following dependencies in your project:
146
129
147
130
```xml
148
131
<dependencies>
149
-
<!-- ConcurrentMap ONLY -->
150
-
<dependency>
151
-
<groupId>wtf.metio.memoization</groupId>
152
-
<artifactId>memoization-map</artifactId>
153
-
<version>${version.memoization}</version>
154
-
</dependency>
155
-
<!-- ConcurrentMap ONLY -->
156
-
157
-
<!-- cache2k ONLY -->
158
-
<dependency>
159
-
<groupId>wtf.metio.memoization</groupId>
160
-
<artifactId>memoization-cache2k</artifactId>
161
-
<version>${version.memoization}</version>
162
-
</dependency>
163
-
<dependency>
164
-
<groupId>org.cache2k</groupId>
165
-
<artifactId>cache2k-api</artifactId>
166
-
<version>${version.cache2k}</version>
167
-
</dependency>
168
-
<dependency>
169
-
<groupId>org.cache2k</groupId>
170
-
<artifactId>cache2k-core</artifactId>
171
-
<version>${version.cache2k}</version>
172
-
<scope>runtime</scope>
173
-
</dependency>
174
-
<!-- cache2k ONLY -->
175
-
176
-
<!-- Caffeine ONLY -->
132
+
<!-- support for JDK interfaces -->
177
133
<dependency>
178
134
<groupId>wtf.metio.memoization</groupId>
179
-
<artifactId>memoization-caffeine</artifactId>
135
+
<artifactId>memoization-jdk</artifactId>
180
136
<version>${version.memoization}</version>
181
137
</dependency>
182
-
<dependency>
183
-
<groupId>com.github.ben-manes.caffeine</groupId>
184
-
<artifactId>caffeine</artifactId>
185
-
<version>${version.caffeine}</version>
186
-
</dependency>
187
-
<!-- Caffeine ONLY -->
138
+
<!-- support for JDK interfaces -->
188
139
189
-
<!--Guava ONLY-->
140
+
<!--support for jOOL interfaces-->
190
141
<dependency>
191
142
<groupId>wtf.metio.memoization</groupId>
192
-
<artifactId>memoization-guava</artifactId>
143
+
<artifactId>memoization-jool</artifactId>
193
144
<version>${version.memoization}</version>
194
145
</dependency>
195
-
<dependency>
196
-
<groupId>com.google.guava</groupId>
197
-
<artifactId>guava</artifactId>
198
-
<version>${version.guava}</version>
199
-
</dependency>
200
-
<!-- Guava ONLY -->
146
+
<!-- support for jOOL interfaces -->
201
147
202
148
</dependencies>
203
149
```
204
150
205
-
Replace `${version.memoization}` with the latest release. Use [ExpiringMap](https://github.com/jhalterman/expiringmap), [ConcurrentLinkedHashMap](https://github.com/ben-manes/concurrentlinkedhashmap), [Chronicle-Map](https://github.com/OpenHFT/Chronicle-Map), [Cacheonix](http://www.cacheonix.org/) or other `ConcurrentMap` implementations as alternatives to the default `ConcurrentHashMap` used in the `MapMemoize` factory.
151
+
Replace `${version.memoization}` with the latest release.
0 commit comments