6
6
import io .github .xanthic .cache .core .AbstractCacheProvider ;
7
7
import org .infinispan .commons .api .CacheContainerAdmin ;
8
8
import org .infinispan .configuration .cache .ConfigurationBuilder ;
9
- import org .infinispan .configuration .global .GlobalConfigurationBuilder ;
10
9
import org .infinispan .manager .DefaultCacheManager ;
10
+ import org .infinispan .manager .EmbeddedCacheManager ;
11
11
12
12
import java .util .UUID ;
13
13
import java .util .concurrent .TimeUnit ;
18
18
* Implements size and time-based expiry.
19
19
*/
20
20
public final class InfinispanProvider extends AbstractCacheProvider {
21
+ private static final EmbeddedCacheManager MANAGER = new DefaultCacheManager ();
22
+
21
23
@ Override
22
24
public <K , V > Cache <K , V > build (ICacheSpec <K , V > spec ) {
23
- GlobalConfigurationBuilder global = GlobalConfigurationBuilder .defaultClusteredBuilder ();
24
- DefaultCacheManager manager = new DefaultCacheManager (global .build ());
25
-
26
25
ConfigurationBuilder builder = new ConfigurationBuilder ();
26
+ builder .simpleCache (true );
27
27
if (spec .maxSize () != null ) builder .memory ().maxCount (spec .maxSize ());
28
28
handleExpiration (spec .expiryTime (), spec .expiryType (), (time , type ) -> {
29
29
if (type == ExpiryType .POST_WRITE )
@@ -32,9 +32,9 @@ public <K, V> Cache<K, V> build(ICacheSpec<K, V> spec) {
32
32
builder .expiration ().maxIdle (time .toNanos (), TimeUnit .NANOSECONDS );
33
33
});
34
34
35
- org .infinispan .Cache <K , V > cache = manager .administration ()
35
+ org .infinispan .Cache <K , V > cache = MANAGER .administration ()
36
36
.withFlags (CacheContainerAdmin .AdminFlag .VOLATILE )
37
- .getOrCreateCache (UUID .randomUUID ().toString (), builder .build ());
37
+ .createCache (UUID .randomUUID ().toString (), builder .build ());
38
38
39
39
if (spec .removalListener () != null ) {
40
40
cache .addFilteredListener (
0 commit comments