Skip to content

Commit

Permalink
feat: add new plugin type for cache manager
Browse files Browse the repository at this point in the history
   - create cache-common with simple in memory cache implementation
   - use caffeine instead of guava as advice by google for in memory cache
   - make hazelcast cache independent of hazelcast cluster plugin
   - bump hazelcast version
  • Loading branch information
guillaumelamirand committed Apr 19, 2023
1 parent a626355 commit 3bf9804
Show file tree
Hide file tree
Showing 58 changed files with 1,941 additions and 743 deletions.
2 changes: 1 addition & 1 deletion gravitee-node-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>io.gravitee.node</groupId>
<artifactId>gravitee-node</artifactId>
<version>3.1.0-alpha.4</version>
<version>3.1.0-archi-231-cache-manager-SNAPSHOT</version>
</parent>

<artifactId>gravitee-node-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ public interface Cache<K, V> {

Collection<V> values();

V get(K key);
V get(final K key);

V put(K key, V value);
V put(final K key, final V value);

V put(K key, V value, long ttl, TimeUnit ttlUnit);
V put(final K key, final V value, final long ttl, final TimeUnit ttlUnit);

void putAll(Map<? extends K, ? extends V> m);
void putAll(final Map<? extends K, ? extends V> m);

V evict(K key);
V evict(final K key);

void clear();

void addCacheListener(CacheListener<K, V> listener);
String addCacheListener(CacheListener<K, V> listener);

boolean removeCacheListener(CacheListener<K, V> listener);
boolean removeCacheListener(final String listenerCacheId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,30 @@
*/
package io.gravitee.node.api.cache;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
* @author David BRASSELY (david.brassely at graviteesource.com)
* @author GraviteeSource Team
*/
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Builder
public class CacheConfiguration {

private long maxSize = -1;

private long timeToLiveSeconds = -1;

private long timeToIdleSeconds = -1;
@Builder.Default
private boolean distributed = false;

public long getMaxSize() {
return maxSize;
}

public void setMaxSize(long maxSize) {
this.maxSize = maxSize;
}

public long getTimeToLiveSeconds() {
return timeToLiveSeconds;
}

public void setTimeToLiveSeconds(long timeToLiveSeconds) {
this.timeToLiveSeconds = timeToLiveSeconds;
}
@Builder.Default
private long maxSize = -1;

public long getTimeToIdleSeconds() {
return timeToIdleSeconds;
}
@Builder.Default
private long timeToLiveInMs = -1;

public void setTimeToIdleSeconds(long timeToIdleSeconds) {
this.timeToIdleSeconds = timeToIdleSeconds;
}
@Builder.Default
private long timeToIdleInMs = -1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
package io.gravitee.node.api.cache;

/**
* @author Kamiel Ahmadpour (kamiel.ahmadpour at graviteesource.com)
* @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com)
* @author GraviteeSource Team
*/
public interface CacheListener<K, V> {
void onEvent(EntryEvent<K, V> event);
default void onEntryAdded(final K key, final V value) {}

default void onEntryEvicted(final K key, final V value) {}

default void onEntryUpdated(final K key, final V oldValue, final V value) {}

default void onEntryExpired(final K key, final V value) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
*/
package io.gravitee.node.api.cache;

import io.gravitee.common.service.Service;

/**
* @author Kamiel Ahmadpour (kamiel.ahmadpour at graviteesource.com)
* @author GraviteeSource Team
*/
public interface CacheManager {
public interface CacheManager extends Service<CacheManager> {
<K, V> Cache<K, V> getOrCreateCache(String name);

<K, V> Cache<K, V> getOrCreateCache(String name, CacheConfiguration configuration);
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 3bf9804

Please sign in to comment.