angel_redis 1.0.0

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

redis

Pub build status

Redis-enabled services for the Angel framework. RedisService can be used alone, or as the backend of a CacheService, and thereby cache the results of calling an upstream database.

Installation

package:angel_redis requires Angel 2.

In your pubspec.yaml:

dependencies:
    angel_framework: ^2.0.0-alpha
    angel_redis: ^1.0.0

Usage

Pass an instance of RespCommands (from package:resp_client) to the RedisService constructor. You can also pass an optional prefix, which is recommended if you are using angel_redis for multiple logically-separate collections. Redis is a flat key-value store; by prefixing the keys used, angel_redis can provide the experience of using separate stores, rather than a single node.

Without a prefix, there's a chance that different collections can overwrite one another's data.

Notes

  • Neither index, nor modify is atomic; each performs two separate queries.angel_redis stores data as JSON strings, rather than as Redis hashes, so an update-in-place is impossible.
  • index uses Redis' KEYS functionality, so use it sparingly in production, if at all. In a larger database, it can quickly become a bottleneck.
  • remove uses MULTI+EXEC in a transaction.
  • Prefer using update, rather than modify. The former only performs one query, though it does overwrite the current contents for a given key.
  • When calling create, it's possible that you may already have an id in mind to insert into the store. For example, when caching another database, you'll preserve the ID or primary key of an item. angel_redis heeds this. If no id is present, then an ID will be created via an INCR call.

Example

Also present at example/main.dart:

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

main() async {
  var connection = await connectSocket('localhost');
  var client = new RespClient(connection);
  var service = new RedisService(new RespCommands(client), prefix: 'example');

  // Create an object
  await service.create({'id': 'a', 'hello': 'world'});

  // Read it...
  var read = await service.read('a');
  print(read['hello']);

  // Delete it.
  await service.remove('a');

  // Close the connection.
  await connection.close();
}

1.0.0

  • First version.

example/main.dart

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

main() async {
  var connection = await connectSocket('localhost');
  var client = new RespClient(connection);
  var service = new RedisService(new RespCommands(client), prefix: 'example');

  // Create an object
  await service.create({'id': 'a', 'hello': 'world'});

  // Read it...
  var read = await service.read('a');
  print(read['hello']);

  // Delete it.
  await service.remove('a');

  // Close the connection.
  await connection.close();
}

Use this package as a library

1. Depend on it

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


dependencies:
  angel_redis: ^1.0.0

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:angel_redis/angel_redis.dart';
  
Version Uploaded Documentation Archive
1.0.0 Oct 21, 2018 Go to the documentation of angel_redis 1.0.0 Download angel_redis 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.6

Platforms

Detected platforms: Flutter, other

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
angel_framework ^2.0.0-alpha 2.0.0-alpha.14
angel_http_exception ^1.0.0 1.0.0+3
resp_client ^0.1.6 0.1.6
Transitive dependencies
angel_container 1.0.0-alpha.12
angel_model 1.0.0+1
angel_route 3.0.0
body_parser 1.1.1
charcode 1.1.2
code_buffer 1.0.1
collection 1.14.11
combinator 1.0.0+3
convert 2.0.2
crypto 2.0.6
dart2_constant 1.0.2+dart2
file 5.0.6
http2 0.1.9
http_parser 3.1.3
http_server 0.9.8+1
intl 0.15.7
logging 0.11.3+2
matcher 0.12.4
merge_map 1.0.1
meta 1.1.6
mime 0.9.6+2
mock_request 1.0.4
path 1.6.2
quiver 2.0.1
source_span 1.4.1
stack_trace 1.9.3
string_scanner 1.0.4
tuple 1.0.2
typed_data 1.1.6
uuid 1.0.3
Dev dependencies
test ^1.0.0