From 7137dcad5bee51875a1f71c711be1690ab26facb Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sun, 21 Oct 2018 12:41:23 -0400 Subject: [PATCH] Remove works --- lib/src/redis_service.dart | 8 +++++++- test/all_test.dart | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/src/redis_service.dart b/lib/src/redis_service.dart index 882dffbc..9d13ccff 100644 --- a/lib/src/redis_service.dart +++ b/lib/src/redis_service.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:convert'; import 'package:angel_framework/angel_framework.dart'; +import 'package:resp_client/resp_client.dart'; import 'package:resp_client/resp_commands.dart'; class RedisService extends Service> { @@ -58,6 +59,11 @@ class RedisService extends Service> { Future> remove(String id, [Map params]) async { 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); } } diff --git a/test/all_test.dart b/test/all_test.dart index e39c97b2..a95363ba 100644 --- a/test/all_test.dart +++ b/test/all_test.dart @@ -42,4 +42,10 @@ main() async { expect(output, {'id': id, 'bar': 'quux'}); 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); + }); }