spring-data-redis icon indicating copy to clipboard operation
spring-data-redis copied to clipboard

Allow using double-colon as keyspace name through `@RedisHash(value = …)`

Open gpizarro-gfm opened this issue 4 years ago • 3 comments

This may be related to/a duplicate of #1326, but that issue was closed back in 2018.

For this Kotlin example, say I have:

@RedishHash(value = "keysubname", timeToLive = 10L)
data class KeySubname(
    @Id
    val id: Long
    @Indexed
    val ext_id: Long
)

And that keyspace events are enabled in the Spring application:

@EnableRedisRepositories(enableKeyspaceEvents = RedisKeyValueAdapter.EnableKeyspaceEvents.ON_STARTUP)

After saving the hash, it and its index, secondary index, and lookup hashmap are deleted after 10 seconds. This is expected behavior.

However, if I add a colon to the hash's name (and make no other changes):

@RedishHash(value = "key:subname", timeToLive = 10L)
data class KeySubname(
    @Id
    val id: Long
    @Indexed
    val ext_id: Long
)

Then the secondary index and lookup hashmap are not deleted after 10 seconds, leaving a permanent record in the redis db of a hash that no longer exists.

Hopefully this issue can be fixed soon. Please let me know how else I can help.

gpizarro-gfm avatar Jun 23 '21 18:06 gpizarro-gfm

Double-colon is considered to be a separator character and as per https://github.com/spring-projects/spring-data-redis/pull/2100#issuecomment-881256388, allowing double-colon usage in the keyspace name requires a wider revision of the repository support.

mp911de avatar Jul 16 '21 08:07 mp911de

@mp911de: Could this ticket be updated to a more up-to-date milestone? Having this feature would be nice, because some Redis UIs also use the colon to group keys. So using colons allow for organizing keys in a more structured way.

GFriedrich avatar May 16 '24 18:05 GFriedrich