-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec61d4c
commit 1859c8e
Showing
3 changed files
with
84 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:ioredis/ioredis.dart'; | ||
|
||
class RedisMulti { | ||
final Redis _redis; | ||
|
||
final List<List<String>> _commands = <List<String>>[]; | ||
|
||
RedisMulti(this._redis); | ||
|
||
/// set value | ||
RedisMulti set(String key, String value, | ||
[String? option, dynamic optionValue]) { | ||
_commands.add(_redis.getCommandToSetData(key, value, option, optionValue)); | ||
return this; | ||
} | ||
|
||
/// get value | ||
RedisMulti get(String key) { | ||
_commands.add(_redis.getCommandToGetData(key)); | ||
return this; | ||
} | ||
|
||
/// exec multi command | ||
Future<List<dynamic>> exec() async { | ||
await _redis.sendCommand(<String>['MULTI']); | ||
for (List<String> command in _commands) { | ||
await _redis.sendCommand(command); | ||
} | ||
return await _redis.sendCommand(<String>['EXEC']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters