@@ -271,7 +271,7 @@ public Object get(Object id, String keyspace) {
271
271
@Override
272
272
public <T> T get(Object id, String keyspace, Class<T> type) {
273
273
274
- String stringId = asString (id);
274
+ String stringId = toString (id);
275
275
byte[] binId = createKey(keyspace, stringId);
276
276
277
277
RedisCallback<Map<byte[], byte[]>> command = connection -> connection.hGetAll(binId);
@@ -305,7 +305,7 @@ public <T> T delete(Object id, String keyspace, Class<T> type) {
305
305
306
306
if (value != null) {
307
307
308
- byte[] keyToDelete = createKey(keyspace, asString (id));
308
+ byte[] keyToDelete = createKey(keyspace, toString (id));
309
309
310
310
redisOps.execute((RedisCallback<Void>) connection -> {
311
311
@@ -383,6 +383,7 @@ public void deleteAllOf(String keyspace) {
383
383
384
384
connection.del(toBytes(keyspace));
385
385
new IndexWriter(connection, converter).removeAllIndexes(keyspace);
386
+
386
387
return null;
387
388
});
388
389
}
@@ -503,7 +504,7 @@ private RedisUpdateObject fetchDeletePathsFromHashAndUpdateIndex(RedisUpdateObje
503
504
504
505
for (byte[] field : existingFields) {
505
506
506
- if (asString (field).startsWith(path + ".")) {
507
+ if (toString (field).startsWith(path + ".")) {
507
508
508
509
redisUpdateObject.addFieldToRemove(field);
509
510
value = connection.hGet(redisUpdateObject.targetKey, toBytes(field));
@@ -555,11 +556,13 @@ public void clear() {
555
556
// nothing to do
556
557
}
557
558
558
- private String asString(Object value) {
559
- return value instanceof String stringValue ? stringValue
560
- : getConverter().getConversionService().convert(value, String.class);
561
- }
562
-
559
+ /**
560
+ * Creates a new {@link byte[] key} using the given {@link String keyspace} and {@link String id}.
561
+ *
562
+ * @param keyspace {@link String name} of the Redis {@literal keyspace}.
563
+ * @param id {@link String} identifying the key.
564
+ * @return a {@link byte[]} constructed from the {@link String keyspace} and {@link String id}.
565
+ */
563
566
public byte[] createKey(String keyspace, String id) {
564
567
return toBytes(keyspace + ":" + id);
565
568
}
@@ -568,12 +571,13 @@ public byte[] createKey(String keyspace, String id) {
568
571
* Convert given source to binary representation using the underlying {@link ConversionService}.
569
572
*/
570
573
public byte[] toBytes(Object source) {
574
+ return source instanceof byte[] bytes ? bytes
575
+ : getConverter().getConversionService().convert(source, byte[].class);
576
+ }
571
577
572
- if (source instanceof byte[] bytes) {
573
- return bytes;
574
- }
575
-
576
- return converter.getConversionService().convert(source, byte[].class);
578
+ private String toString(Object value) {
579
+ return value instanceof String stringValue ? stringValue
580
+ : getConverter().getConversionService().convert(value, String.class);
577
581
}
578
582
579
583
/**
@@ -734,6 +738,7 @@ private void initKeyExpirationListener() {
734
738
735
739
MappingExpirationListener listener = new MappingExpirationListener(this.messageListenerContainer, this.redisOps,
736
740
this.converter);
741
+
737
742
listener.setKeyspaceNotificationsConfigParameter(keyspaceNotificationsConfigParameter);
738
743
739
744
if (this.eventPublisher != null) {
0 commit comments