You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by GitBox <gi...@apache.org> on 2022/10/25 17:36:04 UTC

[GitHub] [karaf] awrb opened a new pull request, #1677: [DRAFT] [KARAF-6017] - added cache facade

awrb opened a new pull request, #1677:
URL: https://github.com/apache/karaf/pull/1677

   Draft phase (it works but it's not a proper component yet).
   
   I'm opening a pr already so it can be reviewed before putting more work into it.
   
   Some features:
   - it uses ehcache with JSR 107 API
   - the api does not depend on ehcache, so other providers could be added
   - possible to load ehcache configuration from xml
   - some karaf commands for debugging/playing around with the caches
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@karaf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [karaf] awrb commented on pull request #1677: [DRAFT] [KARAF-6017] - added cache facade

Posted by GitBox <gi...@apache.org>.
awrb commented on PR #1677:
URL: https://github.com/apache/karaf/pull/1677#issuecomment-1290946318

   @jbonofre would be great if you can take a look :smiley:  once we agree on the requirements then I'll start adding javadocs, tests, feature etc. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@karaf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [karaf] awrb commented on a diff in pull request #1677: [DRAFT] [KARAF-6017] - added cache facade

Posted by GitBox <gi...@apache.org>.
awrb commented on code in PR #1677:
URL: https://github.com/apache/karaf/pull/1677#discussion_r1005818633


##########
cache/commands/src/main/java/org/apache/karaf/cache/core/commands/Invalidate.java:
##########
@@ -0,0 +1,28 @@
+package org.apache.karaf.cache.core.commands;
+
+import org.apache.karaf.cache.api.CacheService;
+import org.apache.karaf.cache.core.commands.completers.CacheNameCompleter;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Completion;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+@Service
+@Command(scope = "cache", name = "invalidate", description = "")
+public class Invalidate implements Action {
+
+    @Reference
+    CacheService cacheService;
+
+    @Argument(index = 0, required = true)
+    @Completion(CacheNameCompleter.class)
+    String cacheName;
+
+    @Override
+    public Object execute() throws Exception {
+        cacheService.invalidateCache(cacheName);
+        return cacheService + " invalidated";

Review Comment:
   Should be `cacheName + " invalidated";`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@karaf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [karaf] awrb commented on a diff in pull request #1677: [DRAFT] [KARAF-6017] - added cache facade

Posted by GitBox <gi...@apache.org>.
awrb commented on code in PR #1677:
URL: https://github.com/apache/karaf/pull/1677#discussion_r1005817727


##########
cache/commands/src/main/java/org/apache/karaf/cache/core/commands/Create.java:
##########
@@ -0,0 +1,39 @@
+package org.apache.karaf.cache.core.commands;
+
+import org.apache.karaf.cache.api.CacheService;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+import javax.cache.configuration.Configuration;
+import javax.cache.configuration.MutableConfiguration;
+import javax.cache.expiry.CreatedExpiryPolicy;
+import javax.cache.expiry.Duration;
+
+@Service
+@Command(scope = "cache", name = "create", description = "")
+public class Create implements Action {
+
+    @Argument(index = 0, required = true)
+    String cacheName;
+    @Argument(index = 1, required = true)
+    String keyType;
+    @Argument(index = 2, required = true)
+    String valueType;
+    @Reference
+    private CacheService cacheService;
+
+    @Override
+    public Object execute() throws Exception {
+        Class keyClass = Class.forName(keyType);
+        Class valueClass = Class.forName(valueType);
+        Configuration<?, ?> configuration = new MutableConfiguration<>()

Review Comment:
   This is just hard-coded for now but I'll extend this (add arguments to specify the cache size, or the xml configuration path, probably make the key/value type resolution smarter, so something like `cache:create myCache long string <other args>` also works).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@karaf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [karaf] jbonofre commented on a diff in pull request #1677: [DRAFT] [KARAF-6017] - added cache facade

Posted by GitBox <gi...@apache.org>.
jbonofre commented on code in PR #1677:
URL: https://github.com/apache/karaf/pull/1677#discussion_r1005588189


##########
cache/api/src/main/java/org/apache/karaf/cache/api/CacheService.java:
##########
@@ -0,0 +1,17 @@
+package org.apache.karaf.cache.api;

Review Comment:
   Missing ASF header here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@karaf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [karaf] awrb commented on a diff in pull request #1677: [DRAFT] [KARAF-6017] - added cache facade

Posted by GitBox <gi...@apache.org>.
awrb commented on code in PR #1677:
URL: https://github.com/apache/karaf/pull/1677#discussion_r1005696744


##########
cache/api/src/main/java/org/apache/karaf/cache/api/CacheService.java:
##########
@@ -0,0 +1,17 @@
+package org.apache.karaf.cache.api;
+
+import javax.cache.configuration.Configuration;
+import java.util.List;
+
+public interface CacheService {
+
+    <K, V> void createCache(String name, Configuration<K, V> configuration);
+
+    <K, V> V get(String name, K key);
+
+    <K, V> void put(String name, K key, V value);
+
+    void invalidateCache(String name);
+
+    List<String> listCaches();
+}

Review Comment:
   A method to get the entire JSR107 `Cache` (other than get/put) might be useful too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@karaf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [karaf] awrb commented on a diff in pull request #1677: [DRAFT] [KARAF-6017] - added cache facade

Posted by GitBox <gi...@apache.org>.
awrb commented on code in PR #1677:
URL: https://github.com/apache/karaf/pull/1677#discussion_r1005694869


##########
cache/api/src/main/java/org/apache/karaf/cache/api/CacheService.java:
##########
@@ -0,0 +1,17 @@
+package org.apache.karaf.cache.api;

Review Comment:
   It's missing in other places too (still a draft), will fix everything once we know how the interface should look like. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@karaf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [karaf] awrb commented on pull request #1677: [DRAFT] [KARAF-6017] - added cache facade

Posted by GitBox <gi...@apache.org>.
awrb commented on PR #1677:
URL: https://github.com/apache/karaf/pull/1677#issuecomment-1322762974

   @jbonofre I made a proper pull request now (added docs, example, tests etc). I'm happy to introduce any changes if needed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@karaf.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org