resp_client 0.1.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new68

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
}

Changelog

0.1.2

  • Bugfix: Fixed handling of null bulk strings and arrays in deserialization.
  • Added SELECT, FLUSHDB and FLUSHALL commands.
  • Cleaned up dependencies.
  • Changed Dart SDK constraint to Dart 2 stable.

0.1.1

  • Added PEXPIRE command.

0.1.0

  • Initial version

example/example.dart

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);

  final clientList = await commands.clientList();
  print(clientList);

  await commands.select(1);

  final set = await commands.set('test', 'foobar', expire: Duration(seconds: 10));
  print(set);

  final exists = await commands.exists(['test']);
  print(exists);

  final ttl = await commands.ttl('test');
  print(ttl);

  final get = await commands.get('test');
  print(get);

  final del = await commands.del(['test']);
  print(del);

  await commands.flushAll();

  server.close();
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  resp_client: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:resp_client/resp_client.dart';
  
Version Uploaded Documentation Archive
0.1.2 Aug 8, 2018 Go to the documentation of resp_client 0.1.2 Download resp_client 0.1.2 archive
0.1.1 Jul 27, 2018 Go to the documentation of resp_client 0.1.1 Download resp_client 0.1.1 archive
0.1.0 Jul 27, 2018 Go to the documentation of resp_client 0.1.0 Download resp_client 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
36
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
68
Learn more about scoring.

We analyzed this package on Aug 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.11.8

Platforms

Detected platforms: Flutter, other

Primary library: package:resp_client/resp_client.dart with components: io.

Suggestions

The description is too short.

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

Format lib/src/client/respclient.dart.

Run dartfmt to format lib/src/client/respclient.dart.

Format lib/src/client/socket.dart.

Run dartfmt to format lib/src/client/socket.dart.

Format lib/src/client/types.dart.

Run dartfmt to format lib/src/client/types.dart.

Format lib/src/commands/commands.dart.

Run dartfmt to format lib/src/commands/commands.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0