resp_client 0.1.7+1

Dart native
Flutter Android iOS

A RESP (REdis Serialization Protocol) client for Dart. It provides a low-level and high-level API to execute Redis commands.

resp_client #

A RESP (REdis Serialization Protocol) client for Dart. This package contains 2 libraries. resp_client implements the Redis serialization protocol. resp_commands provides an easy to use API for Redis commands.

3 Building blocks #

There 3 fundamental building block:

  • RespServerConnection - A connection to a RESP server
  • RespClient - A RESP client connected to a RESP server implementing the request/response model and the RESP types
  • RespCommands - Easy to use API of the Redis commands

Usage #

Initialization #


import 'package:resp_client/resp_client.dart';
import 'package:resp_client/resp_commands.dart';

void main(List<String> args) async {
  // create a RESP server connection using sockets
  final server = await connectSocket('localhost');

  // create a RESP client using the server connection
  final client = RespClient(server);

  // create RESP commands using the client
  final commands = RespCommands(client);

  // ... execute Redis commands

  // close the server connection
  server.close();
}

Use commands #

If the command needed is already implemented, just use the RespCommands class.


import 'package:resp_client/resp_client.dart';
import 'package:resp_client/resp_commands.dart';

void main(List<String> args) async {

  // ... setup connection and client
  
  // create RESP commands using the client
  final commands = RespCommands(client);

  // execute a command
  final value = await commands.get('someKey');

  // ... close connection
}

Use low-level API #

If the command needed is not implemented, use the low-level API (or create an issue or pull request on GitHub).


import 'package:resp_client/resp_client.dart';
import 'package:resp_client/resp_commands.dart';

void main(List<String> args) async {

  // ... setup connection and client
  
  // execute a command...
  final RespType result1 = await client.writeType(RespArray([RespBulkString('GET'), RespBulkString('someKey')]));

  // ...or shorter
  final RespType result2 = await client.writeArrayOfBulk(['GET', 'someKey']);

  // ... close connection
}

0
likes
90
pub points
40%
popularity

Publisher

blimster.net

A RESP (REdis Serialization Protocol) client for Dart. It provides a low-level and high-level API to execute Redis commands.

Homepage

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on resp_client