Remove works
This commit is contained in:
parent
f1782c581f
commit
7137dcad5b
2 changed files with 13 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:angel_framework/angel_framework.dart';
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
|
import 'package:resp_client/resp_client.dart';
|
||||||
import 'package:resp_client/resp_commands.dart';
|
import 'package:resp_client/resp_commands.dart';
|
||||||
|
|
||||||
class RedisService extends Service<String, Map<String, dynamic>> {
|
class RedisService extends Service<String, Map<String, dynamic>> {
|
||||||
|
@ -58,6 +59,11 @@ class RedisService extends Service<String, Map<String, dynamic>> {
|
||||||
Future<Map<String, dynamic>> remove(String id,
|
Future<Map<String, dynamic>> remove(String id,
|
||||||
[Map<String, dynamic> params]) async {
|
[Map<String, dynamic> params]) async {
|
||||||
var client = respCommands.client;
|
var client = respCommands.client;
|
||||||
throw await client.writeArrayOfBulk(['MULTI']);
|
await client.writeArrayOfBulk(['MULTI']);
|
||||||
|
await client.writeArrayOfBulk(['GET', _applyPrefix(id)]);
|
||||||
|
await client.writeArrayOfBulk(['DEL', _applyPrefix(id)]);
|
||||||
|
var result = await client.writeArrayOfBulk(['EXEC']);
|
||||||
|
var str = result.payload[0] as RespBulkString;
|
||||||
|
return json.decode(str.payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,4 +42,10 @@ main() async {
|
||||||
expect(output, {'id': id, 'bar': 'quux'});
|
expect(output, {'id': id, 'bar': 'quux'});
|
||||||
expect(await service.read(id), output);
|
expect(await service.read(id), output);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('remove', () async {
|
||||||
|
var id = 'gelatin${new DateTime.now().millisecondsSinceEpoch}';
|
||||||
|
var input = await service.create({'id': id, 'bar': 'baz'});
|
||||||
|
expect(await service.remove(id), input);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue