ramu11 commented on code in PR #2046:
URL:
https://github.com/apache/camel-spring-boot/pull/2046#discussion_r4303135953
##########
core/camel-spring-boot/src/main/docs/spring-boot.adoc:
##########
@@ -610,6 +610,56 @@ public class MyRoute extends RouteBuilder {
}
----
+== Spring Cache State Store Support
Review Comment:
addressed
##########
core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/statestore/SpringCacheKeyValueRepository.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot.statestore;
+
+import java.time.Duration;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.camel.spi.KeyValueRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+import org.springframework.util.Assert;
+
+/**
+ * An Apache Camel {@link KeyValueRepository} adapter backed by Spring's
{@link CacheManager}.
+ *
+ * <h3>Design Constraints & Backend Behavior:</h3>
+ * <ul>
+ * <li><strong>TTL Support:</strong> Spring Cache has no standard per-entry
TTL API. Providing a TTL argument
+ * triggers a single {@code WARN} log per repository instance and stores
the entry without expiration.
+ * Users requiring TTL must configure it at the underlying
provider/CacheManager spec level (e.g., Caffeine spec).</li>
+ * <li><strong>Atomicity:</strong> CAS operations ({@code putIfAbsent},
{@code replace}, conditional delete)
+ * delegate to Spring Cache's {@code Cache.putIfAbsent()}. Atomicity
guarantees are provider-dependent
+ * (e.g., atomic in Caffeine, but potentially non-atomic in distributed
backends like Lettuce/Redis).</li>
+ * <li><strong>Enumeration:</strong> {@link #keys()} and {@link #size()}
intentionally throw
+ * {@link UnsupportedOperationException} as Spring Cache does not
provide a portable key enumeration API.</li>
+ * <li><strong>Scope & Multi-Store:</strong> Backed by a single global
{@link CacheManager}. Multiple endpoints
+ * can isolate state by specifying distinct cache/store names while
sharing the same underlying manager.</li>
Review Comment:
addressed
##########
core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/statestore/SpringCacheKeyValueRepository.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot.statestore;
+
+import java.time.Duration;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.camel.spi.KeyValueRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+import org.springframework.util.Assert;
+
+/**
+ * An Apache Camel {@link KeyValueRepository} adapter backed by Spring's
{@link CacheManager}.
+ *
+ * <h3>Design Constraints & Backend Behavior:</h3>
+ * <ul>
+ * <li><strong>TTL Support:</strong> Spring Cache has no standard per-entry
TTL API. Providing a TTL argument
+ * triggers a single {@code WARN} log per repository instance and stores
the entry without expiration.
+ * Users requiring TTL must configure it at the underlying
provider/CacheManager spec level (e.g., Caffeine spec).</li>
+ * <li><strong>Atomicity:</strong> CAS operations ({@code putIfAbsent},
{@code replace}, conditional delete)
Review Comment:
addressed
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]