云快充1.5.0 初始化

This commit is contained in:
3god
2024-10-08 09:38:54 +08:00
parent dea6774942
commit cb19b45919
297 changed files with 18020 additions and 28 deletions

View File

@@ -0,0 +1,17 @@
/**
* 抖音关注:程序员三丙
* 知识星球https://t.zsxq.com/j9b21
*/
package sanbing.jcpp.app.service.cache.pile;
import lombok.Data;
import java.util.UUID;
@Data
public class PileCacheEvictEvent {
private UUID pileId;
private String pileCode;
}

View File

@@ -0,0 +1,47 @@
/**
* 抖音关注:程序员三丙
* 知识星球https://t.zsxq.com/j9b21
*/
package sanbing.jcpp.app.service.cache.pile;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import sanbing.jcpp.infrastructure.cache.VersionedCacheKey;
import java.io.Serial;
import java.util.Optional;
import java.util.UUID;
@Getter
@EqualsAndHashCode
@RequiredArgsConstructor
@Builder
public class PileCacheKey implements VersionedCacheKey {
@Serial
private static final long serialVersionUID = 6366389552842340207L;
private final UUID pileId;
private final String pileCode;
public PileCacheKey(UUID pileId) {
this(pileId, null);
}
public PileCacheKey(String pileCode) {
this(null, pileCode);
}
@Override
public String toString() {
return Optional.ofNullable(pileId).map(UUID::toString).orElse(pileCode);
}
@Override
public boolean isVersioned() {
return pileId != null;
}
}

View File

@@ -0,0 +1,22 @@
/**
* 抖音关注:程序员三丙
* 知识星球https://t.zsxq.com/j9b21
*/
package sanbing.jcpp.app.service.cache.pile;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Service;
import sanbing.jcpp.app.dal.entity.Pile;
import sanbing.jcpp.infrastructure.cache.CacheConstants;
import sanbing.jcpp.infrastructure.cache.VersionedCaffeineCache;
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "caffeine", matchIfMissing = true)
@Service("PileCache")
public class PileCaffeineCache extends VersionedCaffeineCache<PileCacheKey, Pile> {
public PileCaffeineCache(CacheManager cacheManager) {
super(cacheManager, CacheConstants.PILE_CACHE);
}
}

View File

@@ -0,0 +1,33 @@
/**
* 抖音关注:程序员三丙
* 知识星球https://t.zsxq.com/j9b21
*/
package sanbing.jcpp.app.service.cache.pile;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.serializer.SerializationException;
import org.springframework.stereotype.Service;
import sanbing.jcpp.app.dal.entity.Pile;
import sanbing.jcpp.infrastructure.cache.*;
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis")
@Service("PileCache")
public class PileRedisCache extends VersionedRedisCache<PileCacheKey, Pile> {
public PileRedisCache(JCPPRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, LettuceConnectionFactory connectionFactory) {
super(CacheConstants.PILE_CACHE, cacheSpecsMap, connectionFactory, configuration, new JCPPRedisSerializer<>() {
@Override
public byte[] serialize(Pile pile) throws SerializationException {
return JacksonUtil.writeValueAsBytes(pile);
}
@Override
public Pile deserialize(PileCacheKey key, byte[] bytes) throws SerializationException {
return JacksonUtil.fromBytes(bytes, Pile.class);
}
});
}
}

View File

@@ -0,0 +1,41 @@
/**
* 抖音关注:程序员三丙
* 知识星球https://t.zsxq.com/j9b21
*/
package sanbing.jcpp.app.service.cache.session;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.io.Serializable;
import java.util.Optional;
import java.util.UUID;
/**
* @author baigod
*/
@Getter
@EqualsAndHashCode
@RequiredArgsConstructor
@Builder
public class PileSessionCacheKey implements Serializable {
private final UUID pileId;
private final String pileCode;
public PileSessionCacheKey(UUID pileId) {
this(pileId, null);
}
public PileSessionCacheKey(String pileCode) {
this(null, pileCode);
}
@Override
public String toString() {
return Optional.ofNullable(pileId).map(UUID::toString).orElse(pileCode);
}
}

View File

@@ -0,0 +1,24 @@
/**
* 抖音关注:程序员三丙
* 知识星球https://t.zsxq.com/j9b21
*/
package sanbing.jcpp.app.service.cache.session;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Service;
import sanbing.jcpp.app.data.PileSession;
import sanbing.jcpp.infrastructure.cache.CacheConstants;
import sanbing.jcpp.infrastructure.cache.CaffeineTransactionalCache;
/**
* @author baigod
*/
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "caffeine", matchIfMissing = true)
@Service("PileSessionCache")
public class PileSessionCaffeineCache extends CaffeineTransactionalCache<PileSessionCacheKey, PileSession> {
public PileSessionCaffeineCache(CacheManager cacheManager) {
super(cacheManager, CacheConstants.PILE_SESSION_CACHE);
}
}

View File

@@ -0,0 +1,36 @@
/**
* 抖音关注:程序员三丙
* 知识星球https://t.zsxq.com/j9b21
*/
package sanbing.jcpp.app.service.cache.session;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.serializer.SerializationException;
import org.springframework.stereotype.Service;
import sanbing.jcpp.app.data.PileSession;
import sanbing.jcpp.infrastructure.cache.*;
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
/**
* @author baigod
*/
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis")
@Service("PileSessionCache")
public class PileSessionRedisCache extends RedisTransactionalCache<PileSessionCacheKey, PileSession> {
public PileSessionRedisCache(JCPPRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, LettuceConnectionFactory connectionFactory) {
super(CacheConstants.PILE_SESSION_CACHE, cacheSpecsMap, connectionFactory, configuration, new JCPPRedisSerializer<>() {
@Override
public byte[] serialize(PileSession pileSession) throws SerializationException {
return JacksonUtil.writeValueAsBytes(pileSession);
}
@Override
public PileSession deserialize(PileSessionCacheKey key, byte[] bytes) throws SerializationException {
return JacksonUtil.fromBytes(bytes, PileSession.class);
}
});
}
}