Sync cache doc with the last update (#2776)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -32,13 +32,11 @@ serviceMatcher.isFromSelf(event)
|
||||
|
||||
### Caching
|
||||
|
||||
Every node is maintaining its own caches independent from other nodes.
|
||||
Every node is maintaining its own caches independent of the other nodes.
|
||||
So there is no globally shared/synchronized cache instance within the cluster.
|
||||
|
||||
In order to keep nodes in sync, a **TTL (time to live)** can be set for all caches to ensure that after some time the cache is refreshed from the database.
|
||||
To enable the TTL just set the property `hawkbit.cache.global.ttl` (value in milliseconds).
|
||||
|
||||
Of course, you can implement a shared cache, e.g. Redis. See [CacheAutoConfiguration](https://github.com/eclipse-hawkbit/hawkbit/blob/master/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/CacheAutoConfiguration.java).
|
||||
To enable the TTL just set the property `hawkbit.cache.global.ttl` (value in dDhHmMsS format).
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAware.TenantResolver;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.Cache;
|
||||
@@ -34,6 +35,7 @@ import org.springframework.lang.Nullable;
|
||||
* <li>If no tenant is resolved, a global cache manager is used.</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@SuppressWarnings("java:S6548") // singleton holder ensures static access to spring resources in some places
|
||||
public class TenantAwareCacheManager implements CacheManager {
|
||||
@@ -115,7 +117,12 @@ public class TenantAwareCacheManager implements CacheManager {
|
||||
spec = defaultSpec;
|
||||
}
|
||||
}
|
||||
return new CaffeineCache(n, Caffeine.from(spec).build(), false);
|
||||
try {
|
||||
return new CaffeineCache(n, Caffeine.from(spec).build(), false);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
log.error("Invalid cache spec: {}", spec, e);
|
||||
throw new IllegalStateException("Invalid cache spec: " + spec, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ hawkbit.server.ddi.security.authentication.gatewaytoken.enabled=false
|
||||
# Cache configuration,
|
||||
# disable expiration since monolith is expected to be used as an all-in-one hawkBit instance,
|
||||
# i.e. no microservices and 1 replica, then evict should do work
|
||||
hawkbit.cache.ttl=0
|
||||
hawkbit.cache.ttl=0s
|
||||
|
||||
# Optional events
|
||||
hawkbit.server.repository.publish-target-poll-event=false
|
||||
|
||||
@@ -181,7 +181,7 @@ public class RestConfiguration {
|
||||
* @param ex the exception which occurred
|
||||
* @return the entity to be responded containing the response status 500
|
||||
*/
|
||||
@ExceptionHandler(FileStreamingFailedException.class)
|
||||
@ExceptionHandler({ FileStreamingFailedException.class, IllegalStateException.class })
|
||||
public ResponseEntity<Object> handleFileStreamingFailedException(final HttpServletRequest request, final Exception ex) {
|
||||
logRequest(request, ex);
|
||||
|
||||
@@ -274,8 +274,9 @@ public class RestConfiguration {
|
||||
return new ResponseEntity<>(createExceptionInfo(new MultiPartFileUploadException(responseCause)), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler({DataIntegrityViolationException.class})
|
||||
public ResponseEntity<ExceptionInfo> handleDataAccessException(final HttpServletRequest request, final DataIntegrityViolationException ex) {
|
||||
@ExceptionHandler({ DataIntegrityViolationException.class })
|
||||
public ResponseEntity<ExceptionInfo> handleDataAccessException(final HttpServletRequest request,
|
||||
final DataIntegrityViolationException ex) {
|
||||
if (log.isDebugEnabled()) {
|
||||
logRequest(request, ex);
|
||||
} else {
|
||||
|
||||
@@ -77,11 +77,10 @@ Add to your `pom.xml` :
|
||||
|
||||
## Caching
|
||||
|
||||
Every node is maintaining its own caches independent from other nodes. So there is no globally shared/synchronized cache
|
||||
Every node is maintaining its own caches independent of the other nodes. So there is no globally shared/synchronized cache
|
||||
instance within the cluster. In order to keep nodes in sync a TTL (time to live) can be set for all caches to ensure
|
||||
that after some time the cache is refreshed from the database. To enable the TTL just set the property "
|
||||
hawkbit.cache.ttl" (value in milliseconds). Of course you can implement a shared cache, e.g. Redis.
|
||||
See [CacheAutoConfiguration](https://github.com/eclipse-hawkbit/hawkbit/blob/master/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/CacheAutoConfiguration.java)
|
||||
hawkbit.cache.ttl" (value in format dDhHmMsS).
|
||||
|
||||
## Schedulers
|
||||
|
||||
|
||||
Reference in New Issue
Block a user