jaguar_cache_redis 0.1.1 copy "jaguar_cache_redis: ^0.1.1" to clipboard
jaguar_cache_redis: ^0.1.1 copied to clipboard

Dart 1 only

Cache implementation based on Redis

example/example.dart

// Copyright (c) 2017, teja. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'dart:async';
import 'package:jaguar_cache_redis/jaguar_cache_redis.dart';

main() async {
  final cache = new RedisCache(new Duration(minutes: 1));

  // Upsert
  await cache.upsert('one', 1, new Duration(seconds: 5));
  print(await cache.read('one'));

  // Replace
  await cache.replace('one', 2, new Duration(seconds: 5));
  print(await cache.read('one'));

  // Expire
  await new Future.delayed(new Duration(seconds: 5));

  try {
    await cache.read('one');
  } catch (e) {
    print('Success! $e');
  }

  await cache.upsert('one', 1.0, new Duration(seconds: 10));
  await cache.upsert('two', 2.0, new Duration(seconds: 10));

  print(await cache.readMany(['one', 'two']));

  await cache.remove('one');

  try {
    await cache.read('one');
  } catch (e) {
    print('Success! $e');
  }
}
0
likes
30
points
27
downloads

Publisher

unverified uploader

Weekly Downloads

Cache implementation based on Redis

Homepage

License

BSD-3-Clause (license)

Dependencies

jaguar_cache, jaguar_serializer, redis_client

More

Packages that depend on jaguar_cache_redis