19
19
import java .util .Iterator ;
20
20
import java .util .Set ;
21
21
22
+ import org .springframework .data .redis .core .RedisOperations ;
23
+
22
24
/**
23
25
* Redis extension for the {@link Set} contract. Supports {@link Set} specific operations backed by Redis operations.
24
26
*
25
27
* @author Costin Leau
26
28
* @author Christoph Strobl
29
+ * @author Mark Paluch
27
30
*/
28
31
public interface RedisSet <E > extends RedisCollection <E >, Set <E > {
29
32
30
33
/**
31
- * Intersect this set and another {@link RedisSet}.
34
+ * Constructs a new {@link RedisSet} instance.
35
+ *
36
+ * @param key Redis key of this set.
37
+ * @param operations {@link RedisOperations} for the value type of this set.
38
+ * @since 2.6
39
+ */
40
+ static <E > RedisSet <E > create (String key , RedisOperations <String , E > operations ) {
41
+ return new DefaultRedisSet <>(key , operations );
42
+ }
43
+
44
+ /**
45
+ * Diff this set and another {@link RedisSet}.
32
46
*
33
47
* @param set must not be {@literal null}.
34
- * @return a {@link Set} containing the intersecting values.
48
+ * @return a {@link Set} containing the values that differ .
35
49
* @since 1.0
36
50
*/
37
- Set <E > intersect (RedisSet <?> set );
51
+ Set <E > diff (RedisSet <?> set );
38
52
39
53
/**
40
- * Intersect this set and other {@link RedisSet}s.
54
+ * Diff this set and other {@link RedisSet}s.
41
55
*
42
56
* @param sets must not be {@literal null}.
43
- * @return a {@link Set} containing the intersecting values.
57
+ * @return a {@link Set} containing the values that differ .
44
58
* @since 1.0
45
59
*/
46
- Set <E > intersect (Collection <? extends RedisSet <?>> sets );
60
+ Set <E > diff (Collection <? extends RedisSet <?>> sets );
47
61
48
62
/**
49
- * Union this set and another {@link RedisSet}.
63
+ * Create a new {@link RedisSet} by diffing this sorted set and {@link RedisSet} and store result in destination
64
+ * {@code destKey}.
50
65
*
51
66
* @param set must not be {@literal null}.
52
- * @return a {@link Set} containing the combined values.
53
- * @since 2.6
67
+ * @param destKey must not be {@literal null}.
68
+ * @return a new {@link RedisSet} pointing at {@code destKey}.
69
+ * @since 1.0
54
70
*/
55
- Set <E > union (RedisSet <?> set );
71
+ RedisSet <E > diffAndStore (RedisSet <?> set , String destKey );
56
72
57
73
/**
58
- * Union this set and other {@link RedisSet}s.
74
+ * Create a new {@link RedisSet} by diffing this sorted set and the collection {@link RedisSet} and store result in
75
+ * destination {@code destKey}.
59
76
*
60
77
* @param sets must not be {@literal null}.
61
- * @return a {@link Set} containing the combined values.
78
+ * @param destKey must not be {@literal null}.
79
+ * @return a new {@link RedisSet} pointing at {@code destKey}.
62
80
* @since 1.0
63
81
*/
64
- Set <E > union (Collection <? extends RedisSet <?>> sets );
82
+ RedisSet <E > diffAndStore (Collection <? extends RedisSet <?>> sets , String destKey );
65
83
66
84
/**
67
- * Diff this set and another {@link RedisSet}.
85
+ * Intersect this set and another {@link RedisSet}.
68
86
*
69
87
* @param set must not be {@literal null}.
70
- * @return a {@link Set} containing the values that differ .
88
+ * @return a {@link Set} containing the intersecting values .
71
89
* @since 1.0
72
90
*/
73
- Set <E > diff (RedisSet <?> set );
91
+ Set <E > intersect (RedisSet <?> set );
74
92
75
93
/**
76
- * Diff this set and other {@link RedisSet}s.
94
+ * Intersect this set and other {@link RedisSet}s.
77
95
*
78
96
* @param sets must not be {@literal null}.
79
- * @return a {@link Set} containing the values that differ .
97
+ * @return a {@link Set} containing the intersecting values .
80
98
* @since 1.0
81
99
*/
82
- Set <E > diff (Collection <? extends RedisSet <?>> sets );
100
+ Set <E > intersect (Collection <? extends RedisSet <?>> sets );
83
101
84
102
/**
85
103
* Create a new {@link RedisSet} by intersecting this sorted set and {@link RedisSet} and store result in destination
@@ -104,60 +122,56 @@ public interface RedisSet<E> extends RedisCollection<E>, Set<E> {
104
122
RedisSet <E > intersectAndStore (Collection <? extends RedisSet <?>> sets , String destKey );
105
123
106
124
/**
107
- * Create a new {@link RedisSet} by union this sorted set and {@link RedisSet} and store result in destination
108
- * {@code destKey}.
125
+ * Get random element from the set.
109
126
*
110
- * @param set must not be {@literal null}.
111
- * @param destKey must not be {@literal null}.
112
- * @return a new {@link RedisSet} pointing at {@code destKey}.
113
- * @since 1.0
127
+ * @return
128
+ * @since 2.6
114
129
*/
115
- RedisSet < E > unionAndStore ( RedisSet <?> set , String destKey );
130
+ E randomValue ( );
116
131
117
132
/**
118
- * Create a new {@link RedisSet} by union this sorted set and the collection {@link RedisSet} and store result in
119
- * destination {@code destKey}.
120
- *
121
- * @param sets must not be {@literal null}.
122
- * @param destKey must not be {@literal null}.
123
- * @return a new {@link RedisSet} pointing at {@code destKey}.
124
- * @since 1.0
133
+ * @since 1.4
134
+ * @return
125
135
*/
126
- RedisSet <E > unionAndStore ( Collection <? extends RedisSet <?>> sets , String destKey );
136
+ Iterator <E > scan ( );
127
137
128
138
/**
129
- * Get random element from the set .
139
+ * Union this set and another {@link RedisSet} .
130
140
*
131
- * @return
141
+ * @param set must not be {@literal null}.
142
+ * @return a {@link Set} containing the combined values.
132
143
* @since 2.6
133
144
*/
134
- E randomValue ( );
145
+ Set < E > union ( RedisSet <?> set );
135
146
136
147
/**
137
- * Create a new {@link RedisSet} by diffing this sorted set and {@link RedisSet} and store result in destination
148
+ * Union this set and other {@link RedisSet}s.
149
+ *
150
+ * @param sets must not be {@literal null}.
151
+ * @return a {@link Set} containing the combined values.
152
+ * @since 1.0
153
+ */
154
+ Set <E > union (Collection <? extends RedisSet <?>> sets );
155
+
156
+ /**
157
+ * Create a new {@link RedisSet} by union this sorted set and {@link RedisSet} and store result in destination
138
158
* {@code destKey}.
139
159
*
140
160
* @param set must not be {@literal null}.
141
161
* @param destKey must not be {@literal null}.
142
162
* @return a new {@link RedisSet} pointing at {@code destKey}.
143
163
* @since 1.0
144
164
*/
145
- RedisSet <E > diffAndStore (RedisSet <?> set , String destKey );
165
+ RedisSet <E > unionAndStore (RedisSet <?> set , String destKey );
146
166
147
167
/**
148
- * Create a new {@link RedisSet} by diffing this sorted set and the collection {@link RedisSet} and store result in
168
+ * Create a new {@link RedisSet} by union this sorted set and the collection {@link RedisSet} and store result in
149
169
* destination {@code destKey}.
150
170
*
151
171
* @param sets must not be {@literal null}.
152
172
* @param destKey must not be {@literal null}.
153
173
* @return a new {@link RedisSet} pointing at {@code destKey}.
154
174
* @since 1.0
155
175
*/
156
- RedisSet <E > diffAndStore (Collection <? extends RedisSet <?>> sets , String destKey );
157
-
158
- /**
159
- * @since 1.4
160
- * @return
161
- */
162
- Iterator <E > scan ();
176
+ RedisSet <E > unionAndStore (Collection <? extends RedisSet <?>> sets , String destKey );
163
177
}
0 commit comments