pip_services3_redis 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

Pip.Services Logo #

Redis components for Dart #

This component library is a part of Pip.Services project. It contains Redis components: RedisCache and RedisLock

Quick Links:

Acknowledgements #

The library is created and maintained by:

  • Sergey Seroukhov
  • Levichev Dmitry

The documentation is written by:

  • Mark Makarychev
  • Levichev Dmitry

Redis components for Pip.Services in Dart Changelog #

1.0.0 #

  • Initial version, created by Sergey Seroukhov and Dmitry Levichev

example/main.dart

import 'dart:io';
import 'package:pip_services3_commons/pip_services3_commons.dart';
import 'package:pip_services3_redis/pip_services3_redis.dart';

void main() async {
  final LOCK1 = 'lock_1';
  final LOCK2 = 'lock_2';

  RedisLock _lock;

  var host = Platform.environment['REDIS_SERVICE_HOST'] ?? 'localhost';
  var port = Platform.environment['REDIS_SERVICE_PORT'] ?? 6379;

  _lock = RedisLock();

  var config = ConfigParams.fromTuples(
      ['connection.host', host, 'connection.port', port]);
  _lock.configure(config);

  await _lock.open(null);

  // Try to acquire lock for the first time
  var result = await _lock.tryAcquireLock('123', LOCK1, 3000); // true

  // Try to acquire lock for the second time
  result = await _lock.tryAcquireLock('123', LOCK1, 3000); // false

  // Release the lock
  await _lock.releaseLock('123', LOCK1);

  // Acquire lock for the first time
  await _lock.acquireLock('123', LOCK2, 3000, 1000);
  // Acquire lock for the second time
  try {
    await _lock.acquireLock('123', LOCK2, 3000, 1000); // error
  } catch (err) {
    // error handle
  }

  // Release the lock
  await _lock.releaseLock('123', LOCK2);

  await _lock.close(null);
}

Use this package as a library

1. Depend on it

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


dependencies:
  pip_services3_redis: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:pip_services3_redis/pip_services3_redis.dart';
  
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 May 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.2
  • pana: 0.13.8-dev

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
pip_services3_commons >=1.0.4 <2.0.0 1.0.9
pip_services3_components >=1.0.5 <2.0.0 1.0.6
redis ^1.3.0 1.3.0
Transitive dependencies
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.5
meta 1.1.8
mustache4dart2 0.1.0
path 1.7.0
source_span 1.7.0
sprintf 4.0.2
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
uuid 2.0.4
yaml 2.2.1
Dev dependencies
test >=1.14.2 <2.0.0