You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2018/02/18 19:15:50 UTC
incubator-unomi git commit: UNOMI-166 Experiment : introduce a
back-end cache for the ElasticSearch persistence manager - Change the map key
to use the class name instead of a custom naming scheme.
Repository: incubator-unomi
Updated Branches:
refs/heads/master 952ad8f8c -> 162660191
UNOMI-166 Experiment : introduce a back-end cache for the ElasticSearch persistence manager
- Change the map key to use the class name instead of a custom naming scheme.
Signed-off-by: Serge Huber <sh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/16266019
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/16266019
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/16266019
Branch: refs/heads/master
Commit: 162660191f63c7ff84cd2a101d62a1694c93dfe4
Parents: 952ad8f
Author: Serge Huber <sh...@apache.org>
Authored: Sun Feb 18 20:15:42 2018 +0100
Committer: Serge Huber <sh...@apache.org>
Committed: Sun Feb 18 20:15:42 2018 +0100
----------------------------------------------------------------------
.../ElasticSearchPersistenceServiceImpl.java | 22 ++++++++++----------
1 file changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/16266019/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
----------------------------------------------------------------------
diff --git a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
index 3062dc7..3dfcc2d 100644
--- a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
+++ b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
@@ -1871,40 +1871,40 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
return null;
}
- private <T extends Item> boolean isCacheActiveForClass(Class<T> clazz) {
+ private <T extends Item> boolean isCacheActiveForClass(String className) {
if (itemClassesToCacheSet.contains("*")) {
return true;
}
- if (itemClassesToCacheSet.contains(clazz.getName())) {
+ if (itemClassesToCacheSet.contains(className)) {
return true;
}
return false;
}
private <T extends Item> T getFromCache(String itemId, Class<T> clazz) {
- if (!isCacheActiveForClass(clazz)) {
+ String className = clazz.getName();
+ if (!isCacheActiveForClass(className)) {
return null;
}
- String itemType = Item.getItemType(clazz);
- Map<String,T> itemCache = hazelcastInstance.getMap("org.apache.unomi.persistence." + itemType);
+ Map<String,T> itemCache = hazelcastInstance.getMap(className);
return itemCache.get(itemId);
}
private <T extends Item> T putInCache(String itemId, T item) {
- if (!isCacheActiveForClass(item.getClass())) {
+ String className = item.getClass().getName();
+ if (!isCacheActiveForClass(className)) {
return null;
}
- String itemType = Item.getItemType(item.getClass());
- Map<String,T> itemCache = hazelcastInstance.getMap("org.apache.unomi.persistence." + itemType);
+ Map<String,T> itemCache = hazelcastInstance.getMap(className);
return itemCache.put(itemId, item);
}
private <T extends Item> T deleteFromCache(String itemId, Class clazz) {
- if (!isCacheActiveForClass(clazz)) {
+ String className = clazz.getName();
+ if (!isCacheActiveForClass(className)) {
return null;
}
- String itemType = Item.getItemType(clazz);
- Map<String,T> itemCache = hazelcastInstance.getMap("org.apache.unomi.persistence." + itemType);
+ Map<String,T> itemCache = hazelcastInstance.getMap(className);
return itemCache.remove(itemId);
}