feat(redis_client): add MSET (#3017)
This commit is contained in:
+2
-1
@@ -45,7 +45,7 @@ words:
|
||||
- gradlew
|
||||
- hotreload
|
||||
- idevicesyslog
|
||||
- incrbyfloat # From redis_client
|
||||
- incrbyfloat # From ./packages/redis_client
|
||||
- iokit
|
||||
- iphoneos
|
||||
- keyalg # From .github/workflows/e2e.yaml
|
||||
@@ -66,6 +66,7 @@ words:
|
||||
- metadatas
|
||||
- mktemp
|
||||
- mocktail
|
||||
- mset # From ./packages/redis_client
|
||||
- multioption
|
||||
- noaudio # From .github dir, doesn't show up in "**" check?
|
||||
- NOAUTH
|
||||
|
||||
@@ -182,6 +182,17 @@ class RedisClient {
|
||||
]);
|
||||
}
|
||||
|
||||
/// Sets the given keys to their respective values. MSET replaces existing
|
||||
/// values with new values, just as regular SET.
|
||||
/// Equivalent to the `MSET` command.
|
||||
/// https://redis.io/commands/mset
|
||||
Future<void> mset({required List<({String key, String value})> pairs}) async {
|
||||
return execute([
|
||||
'MSET',
|
||||
for (final pair in pairs) ...[pair.key, pair.value],
|
||||
]);
|
||||
}
|
||||
|
||||
/// Gets the value of a key.
|
||||
/// Returns null if the key does not exist.
|
||||
/// Equivalent to the `GET` command.
|
||||
|
||||
@@ -252,19 +252,13 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('MGET', () {
|
||||
group('MGET/MSET', () {
|
||||
final kvPairs = [
|
||||
for (var i = 0; i < 10; i++) (key: 'key_$i', value: 'value_$i'),
|
||||
];
|
||||
|
||||
setUp(() async {
|
||||
await client.connect();
|
||||
for (final pair in kvPairs) {
|
||||
await expectLater(
|
||||
client.set(key: pair.key, value: pair.value),
|
||||
completes,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
@@ -280,6 +274,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('completes', () async {
|
||||
await expectLater(client.mset(pairs: kvPairs), completes);
|
||||
await expectLater(
|
||||
client.mget(keys: kvPairs.map((pair) => pair.key).toList()),
|
||||
completion(equals(kvPairs.map((pair) => pair.value).toList())),
|
||||
|
||||
Reference in New Issue
Block a user