|
27 | 27 | import java.util.concurrent.TimeUnit;
|
28 | 28 | import java.util.concurrent.atomic.AtomicReference;
|
29 | 29 |
|
30 |
| -import org.slf4j.Logger; |
31 |
| -import org.slf4j.LoggerFactory; |
32 | 30 | import org.springframework.beans.BeansException;
|
33 | 31 | import org.springframework.beans.factory.InitializingBean;
|
34 | 32 | import org.springframework.context.ApplicationContext;
|
|
52 | 50 | import org.springframework.data.redis.core.convert.GeoIndexedPropertyValue;
|
53 | 51 | import org.springframework.data.redis.core.convert.KeyspaceConfiguration;
|
54 | 52 | import org.springframework.data.redis.core.convert.MappingRedisConverter;
|
| 53 | +import org.springframework.data.redis.core.convert.MappingRedisConverter.BinaryKeyspaceIdentifier; |
| 54 | +import org.springframework.data.redis.core.convert.MappingRedisConverter.KeyspaceIdentifier; |
55 | 55 | import org.springframework.data.redis.core.convert.PathIndexResolver;
|
56 | 56 | import org.springframework.data.redis.core.convert.RedisConverter;
|
57 | 57 | import org.springframework.data.redis.core.convert.RedisData;
|
|
64 | 64 | import org.springframework.data.util.CloseableIterator;
|
65 | 65 | import org.springframework.util.Assert;
|
66 | 66 | import org.springframework.util.ObjectUtils;
|
67 |
| -import org.springframework.util.StringUtils; |
68 | 67 |
|
69 | 68 | /**
|
70 | 69 | * Redis specific {@link KeyValueAdapter} implementation. Uses binary codec to read/write data from/to Redis. Objects
|
@@ -228,7 +227,7 @@ public Object doInRedis(RedisConnection connection) throws DataAccessException {
|
228 | 227 | connection.expire(objectKey, rdo.getTimeToLive().longValue());
|
229 | 228 |
|
230 | 229 | // add phantom key so values can be restored
|
231 |
| - byte[] phantomKey = ByteUtils.concat(objectKey, toBytes(":phantom")); |
| 230 | + byte[] phantomKey = ByteUtils.concat(objectKey, BinaryKeyspaceIdentifier.PHANTOM_SUFFIX); |
232 | 231 | connection.del(phantomKey);
|
233 | 232 | connection.hMSet(phantomKey, rdo.getBucket().rawMap());
|
234 | 233 | connection.expire(phantomKey, rdo.getTimeToLive().longValue() + 300);
|
@@ -484,14 +483,14 @@ public Void doInRedis(RedisConnection connection) throws DataAccessException {
|
484 | 483 | connection.expire(redisKey, rdo.getTimeToLive().longValue());
|
485 | 484 |
|
486 | 485 | // add phantom key so values can be restored
|
487 |
| - byte[] phantomKey = ByteUtils.concat(redisKey, toBytes(":phantom")); |
| 486 | + byte[] phantomKey = ByteUtils.concat(redisKey, BinaryKeyspaceIdentifier.PHANTOM_SUFFIX); |
488 | 487 | connection.hMSet(phantomKey, rdo.getBucket().rawMap());
|
489 | 488 | connection.expire(phantomKey, rdo.getTimeToLive().longValue() + 300);
|
490 | 489 |
|
491 | 490 | } else {
|
492 | 491 |
|
493 | 492 | connection.persist(redisKey);
|
494 |
| - connection.persist(ByteUtils.concat(redisKey, toBytes(":phantom"))); |
| 493 | + connection.persist(ByteUtils.concat(redisKey, BinaryKeyspaceIdentifier.PHANTOM_SUFFIX)); |
495 | 494 | }
|
496 | 495 | }
|
497 | 496 |
|
@@ -779,7 +778,7 @@ public void onMessage(Message message, byte[] pattern) {
|
779 | 778 | byte[] key = message.getBody();
|
780 | 779 |
|
781 | 780 | final byte[] phantomKey = ByteUtils.concat(key,
|
782 |
| - converter.getConversionService().convert(":phantom", byte[].class)); |
| 781 | + converter.getConversionService().convert(KeyspaceIdentifier.PHANTOM_SUFFIX, byte[].class)); |
783 | 782 |
|
784 | 783 | Map<byte[], byte[]> hash = ops.execute(new RedisCallback<Map<byte[], byte[]>>() {
|
785 | 784 |
|
@@ -822,12 +821,7 @@ private boolean isKeyExpirationMessage(Message message) {
|
822 | 821 | return false;
|
823 | 822 | }
|
824 | 823 |
|
825 |
| - byte[][] args = ByteUtils.split(message.getBody(), ':'); |
826 |
| - if (args.length != 2) { |
827 |
| - return false; |
828 |
| - } |
829 |
| - |
830 |
| - return true; |
| 824 | + return BinaryKeyspaceIdentifier.isValid(message.getBody()); |
831 | 825 | }
|
832 | 826 | }
|
833 | 827 |
|
|
0 commit comments