redis_dart
一个简单且极简的 Dart Redis 客户端
用法
import 'package:redis_dart/redis_dart.dart';
void main() async {
final client = await RedisClient.connect('localhost');
await client.set('name', 'Gabriel');
var res = await client.get('name');
print(res);
await client.close();
}
易于使用
这个库的目标是清晰易懂,所以方法名和函数的功能相关联,例如
void main() async {
final client = await RedisClient.connect('localhost');
// this is a HSET command
await client.setMap('info', {
'name': 'John Doe',
'email': '[email protected]',
'age': 34,
});
// this one is a HGETALL
var info = await client.getMap('info');
print(info);
await client.close();
}
返回一个Map并打印
{name: John Doe, email: [email protected], age: 34}
这样,插入一个 Redis Hash 就像传递一个 Dart Map 一样简单。
API
有关完整的 API 文档,请查看 https://pub.dev/documentation/redis_dart/latest/
另外,请查看 examples 目录。