GitXplorerGitXplorer
b

ttl_cache

public
1 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
f29d099e5be5c527da6fd5b0cc24d98039cd154e

Merge pull request #4 from bryanoltman/bo/upgrade-analysis-options

bbryanoltman committed a month ago
Unverified
f3a3fe1cd256932edd78bc5da2fe989964db5587

chore: upgrade analysis_options

bbryanoltman committed a month ago
Verified
dd8165c2c3e9b87a77721fa3dbb9262ff23b70fd

Merge pull request #3 from bryanoltman/dependabot/pub/very_good_analysis-7.0.0

bbryanoltman committed a month ago
Verified
f38bf52f576f8a4345e2d8b0ed90de171439d46b

Bump very_good_analysis from 6.0.0 to 7.0.0

ddependabot[bot] committed a month ago
Verified
ad25a73af30b8c48493298f428d3358a48b731aa

Merge pull request #2 from bryanoltman/dependabot/pub/very_good_analysis-6.0.0

bbryanoltman committed 7 months ago
Verified
14c6b5444d7ba35e8ab85c81f623147f370067c1

Bump very_good_analysis from 5.1.0 to 6.0.0

ddependabot[bot] committed 7 months ago

README

The README file for this repository.

ttl_cache

Powered by Mason License: MIT

A simple Dart key-value store with optional entry expiration.

Usage

A simple usage example:

import 'package:ttl_cache/ttl_cache.dart';

void main() {
  final cache = TtlCache<String, int>(defaultTtl: Duration(seconds: 1));

  // Set 'a' and 'b' with a default TTL of 1 second.
  // These lines are equivalent.
  cache['a'] = 1;
  cache.set('b', 2);

  // Set 'c' with a TTL of 3 seconds.
  cache.set('c', 3, ttl: Duration(seconds: 3));

  // Set 'd' with no TTL. This entry will remain in the cache until it is
  // manually removed.
  cache.set('d', 4, ttl: null);

  print(cache['a']); // 1
  print(cache['b']); // 2
  print(cache['c']); // 3
  print(cache['d']); // 4

  // Entries with the default TTL will have expired. 'c' has a TTL of 3 seconds
  // and will still be available.
  Future.delayed(Duration(seconds: 2), () {
    print(cache['a']); // null
    print(cache['b']); // null
    print(cache['c']); // 3
    print(cache['d']); // 4
  });

  // All entries from above with TTLs will have expired. 'd' has no TTL and will
  // still be available.
  Future.delayed(Duration(seconds: 4), () {
    // 'a' and 'b' will still be null
    print(cache['c']); // null
    print(cache['d']); // 4
  });
}