2021-06-21 01:58:05 +00:00
|
|
|
import 'package:angel3_redis/angel3_redis.dart';
|
2018-10-21 18:12:54 +00:00
|
|
|
import 'package:resp_client/resp_client.dart';
|
|
|
|
import 'package:resp_client/resp_commands.dart';
|
2021-06-20 12:37:20 +00:00
|
|
|
import 'package:resp_client/resp_server.dart';
|
2018-10-21 18:08:24 +00:00
|
|
|
|
2021-06-20 12:37:20 +00:00
|
|
|
void main() async {
|
2018-10-21 18:12:54 +00:00
|
|
|
var connection = await connectSocket('localhost');
|
2021-06-20 12:37:20 +00:00
|
|
|
var client = RespClient(connection);
|
|
|
|
var service = RedisService(RespCommandsTier2(client), prefix: 'example');
|
2018-10-21 18:12:54 +00:00
|
|
|
|
|
|
|
// Create an object
|
|
|
|
await service.create({'id': 'a', 'hello': 'world'});
|
|
|
|
|
|
|
|
// Read it...
|
2021-06-20 12:37:20 +00:00
|
|
|
var read = await (service.read('a'));
|
2018-10-21 18:12:54 +00:00
|
|
|
print(read['hello']);
|
|
|
|
|
|
|
|
// Delete it.
|
|
|
|
await service.remove('a');
|
|
|
|
|
|
|
|
// Close the connection.
|
|
|
|
await connection.close();
|
|
|
|
}
|