stash_memory 3.0.0-dev.2 copy "stash_memory: ^3.0.0-dev.2" to clipboard
stash_memory: ^3.0.0-dev.2 copied to clipboard

outdated

Memory storage extension for the stash caching API. Provides support to store caches in-memory

example/example.dart

import 'package:stash/stash_api.dart';
import 'package:stash_memory/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, eventListenerMode: EventListenerMode.Sync)
    ..on<CreatedEntryEvent>().listen(
        (event) => print('Entry key "${event.entry.key}" added to the cache'));

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

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

Publisher

verified publisherivoleitao.dev

Memory storage extension for the stash caching API. Provides support to store caches in-memory

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

stash

More

Packages that depend on stash_memory