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:

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 RespServerConnection server = await connectSocket('localhost');

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

  // create RESP commands using the client
  RespCommands 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
  RespCommands commands = RespCommands(client);

  // execute a command
  final String 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 result = await client.writeType(RespArray([RespBulkString('GET'), RespBulkString('someKey')]));

  // ... close connection
}

Libraries

resp_client
resp_commands