stash 1.0.0-dev.1 copy "stash: ^1.0.0-dev.1" to clipboard
stash: ^1.0.0-dev.1 copied to clipboard

outdated

Standard caching API for Dart. Defines a common mechanism to create, access, update, and remove information from caches. Provides a in memory reference implementation

example/example.dart

import 'package:stash/stash_memory.dart';

class Task {
  final int id;
  final String title;
  final bool completed;

  Task({this.id, this.title, this.completed = false});

  @override
  String toString() {
    return 'Task ${id}: "${title}" is ${completed ? "completed" : "not completed"}';
  }
}

void main() async {
  // Creates a memory based cache with a a capacity of 10
  final cache = newMemoryCache(maxEntries: 10);

  // Adds a task with key 'task1' to the cache
  await cache.put(
      'task1', Task(id: 1, title: 'Run stash_memory example', completed: true));
  // Retrieves the value from the cache
  final value = await cache.get('task1');

  print(value);
}
140
likes
0
pub points
85%
popularity

Publisher

verified publisherivoleitao.dev

Standard caching API for Dart. Defines a common mechanism to create, access, update, and remove information from caches. Provides a in memory reference implementation

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

equatable, matcher, quiver, time, uuid

More

Packages that depend on stash