-
Notifications
You must be signed in to change notification settings - Fork 101
Closed
Description
Redis Cluster implements a concept called hash tags that can be used to force certain keys to be stored in the same hash slot. However, during manual resharding, multi-key operations may become unavailable for some time while single-key operations are always available.
Using the @IdFilter
one can provide a class that can transform the ID portion of the Redis Key:
@Document("dwht")
public class DocWithHashTagId {
@Id
@IdFilter(value = IdAsHashTag.class)
private String id;
@Indexed
@NonNull
private String name;
}
One simple implementation of the IdentifierFilter
interface is provided as shown above IdAsHashTag
:
public class IdAsHashTag implements IdentifierFilter<Object> {
@Override
public String filter(Object id) {
return "{" + id.toString() + "}";
}
}
Which adds {
and }
around the ID portion of the key, int he case above keys will look like:
"dwht:{01HZQGRZ2JC5YR3W18CGQM6RP4}"
Metadata
Metadata
Assignees
Labels
No labels