Rename CacheKey to VersionedCacheKey
This commit is contained in:
parent
53a975681c
commit
cf0d3183e7
@ -17,7 +17,7 @@ package org.thingsboard.server.cache;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public interface CacheKey extends Serializable {
|
public interface VersionedCacheKey extends Serializable {
|
||||||
|
|
||||||
default boolean isVersioned() {
|
default boolean isVersioned() {
|
||||||
return false;
|
return false;
|
||||||
@ -22,7 +22,7 @@ import org.thingsboard.server.common.data.util.TbPair;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public abstract class VersionedCaffeineTbCache<K extends CacheKey, V extends Serializable & HasVersion> extends CaffeineTbTransactionalCache<K, V> implements VersionedTbCache<K, V> {
|
public abstract class VersionedCaffeineTbCache<K extends VersionedCacheKey, V extends Serializable & HasVersion> extends CaffeineTbTransactionalCache<K, V> implements VersionedTbCache<K, V> {
|
||||||
|
|
||||||
public VersionedCaffeineTbCache(CacheManager cacheManager, String cacheName) {
|
public VersionedCaffeineTbCache(CacheManager cacheManager, String cacheName) {
|
||||||
super(cacheManager, cacheName);
|
super(cacheManager, cacheName);
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import java.io.Serializable;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class VersionedRedisTbCache<K extends CacheKey, V extends Serializable & HasVersion> extends RedisTbTransactionalCache<K, V> implements VersionedTbCache<K, V> {
|
public abstract class VersionedRedisTbCache<K extends VersionedCacheKey, V extends Serializable & HasVersion> extends RedisTbTransactionalCache<K, V> implements VersionedTbCache<K, V> {
|
||||||
|
|
||||||
private static final int VERSION_SIZE = 8;
|
private static final int VERSION_SIZE = 8;
|
||||||
private static final int VALUE_END_OFFSET = -1;
|
private static final int VALUE_END_OFFSET = -1;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import java.util.Collection;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public interface VersionedTbCache<K extends CacheKey, V extends Serializable & HasVersion> extends TbTransactionalCache<K, V> {
|
public interface VersionedTbCache<K extends VersionedCacheKey, V extends Serializable & HasVersion> extends TbTransactionalCache<K, V> {
|
||||||
|
|
||||||
TbCacheValueWrapper<V> get(K key);
|
TbCacheValueWrapper<V> get(K key);
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import lombok.Builder;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.thingsboard.server.cache.CacheKey;
|
import org.thingsboard.server.cache.VersionedCacheKey;
|
||||||
import org.thingsboard.server.common.data.id.DeviceId;
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ import java.io.Serial;
|
|||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
public class DeviceCacheKey implements CacheKey {
|
public class DeviceCacheKey implements VersionedCacheKey {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 6366389552842340207L;
|
private static final long serialVersionUID = 6366389552842340207L;
|
||||||
|
|||||||
@ -16,14 +16,14 @@
|
|||||||
package org.thingsboard.server.dao.asset;
|
package org.thingsboard.server.dao.asset;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.thingsboard.server.cache.CacheKey;
|
import org.thingsboard.server.cache.VersionedCacheKey;
|
||||||
import org.thingsboard.server.common.data.id.AssetProfileId;
|
import org.thingsboard.server.common.data.id.AssetProfileId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class AssetProfileCacheKey implements CacheKey {
|
public class AssetProfileCacheKey implements VersionedCacheKey {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 8220455917177676472L;
|
private static final long serialVersionUID = 8220455917177676472L;
|
||||||
|
|||||||
@ -18,7 +18,7 @@ package org.thingsboard.server.dao.attributes;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.thingsboard.server.cache.CacheKey;
|
import org.thingsboard.server.cache.VersionedCacheKey;
|
||||||
import org.thingsboard.server.common.data.AttributeScope;
|
import org.thingsboard.server.common.data.AttributeScope;
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ import java.io.Serial;
|
|||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class AttributeCacheKey implements CacheKey {
|
public class AttributeCacheKey implements VersionedCacheKey {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 2013369077925351881L;
|
private static final long serialVersionUID = 2013369077925351881L;
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
package org.thingsboard.server.dao.device;
|
package org.thingsboard.server.dao.device;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.thingsboard.server.cache.CacheKey;
|
import org.thingsboard.server.cache.VersionedCacheKey;
|
||||||
import org.thingsboard.server.common.data.StringUtils;
|
import org.thingsboard.server.common.data.StringUtils;
|
||||||
import org.thingsboard.server.common.data.id.DeviceProfileId;
|
import org.thingsboard.server.common.data.id.DeviceProfileId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
@ -24,7 +24,7 @@ import org.thingsboard.server.common.data.id.TenantId;
|
|||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class DeviceProfileCacheKey implements CacheKey {
|
public class DeviceProfileCacheKey implements VersionedCacheKey {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 8220455917177676472L;
|
private static final long serialVersionUID = 8220455917177676472L;
|
||||||
|
|||||||
@ -16,13 +16,13 @@
|
|||||||
package org.thingsboard.server.dao.entity;
|
package org.thingsboard.server.dao.entity;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.thingsboard.server.cache.CacheKey;
|
import org.thingsboard.server.cache.VersionedCacheKey;
|
||||||
import org.thingsboard.server.cache.VersionedTbCache;
|
import org.thingsboard.server.cache.VersionedTbCache;
|
||||||
import org.thingsboard.server.common.data.HasVersion;
|
import org.thingsboard.server.common.data.HasVersion;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public abstract class CachedVersionedEntityService<K extends CacheKey, V extends Serializable & HasVersion, E> extends AbstractCachedEntityService<K, V, E> {
|
public abstract class CachedVersionedEntityService<K extends VersionedCacheKey, V extends Serializable & HasVersion, E> extends AbstractCachedEntityService<K, V, E> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected VersionedTbCache<K, V> cache;
|
protected VersionedTbCache<K, V> cache;
|
||||||
|
|||||||
@ -18,7 +18,7 @@ package org.thingsboard.server.dao.entityview;
|
|||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.thingsboard.server.cache.CacheKey;
|
import org.thingsboard.server.cache.VersionedCacheKey;
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
import org.thingsboard.server.common.data.id.EntityViewId;
|
import org.thingsboard.server.common.data.id.EntityViewId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
@ -28,7 +28,7 @@ import java.io.Serial;
|
|||||||
@Getter
|
@Getter
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@Builder
|
@Builder
|
||||||
public class EntityViewCacheKey implements CacheKey {
|
public class EntityViewCacheKey implements VersionedCacheKey {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 5986277528222738163L;
|
private static final long serialVersionUID = 5986277528222738163L;
|
||||||
|
|||||||
@ -18,7 +18,7 @@ package org.thingsboard.server.dao.timeseries;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.thingsboard.server.cache.CacheKey;
|
import org.thingsboard.server.cache.VersionedCacheKey;
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
@ -26,7 +26,7 @@ import java.io.Serial;
|
|||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class TsLatestCacheKey implements CacheKey {
|
public class TsLatestCacheKey implements VersionedCacheKey {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 2024369077925351881L;
|
private static final long serialVersionUID = 2024369077925351881L;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user