Skip to content

This is not LRU. #2

@LacticWhale

Description

@LacticWhale

LRU stand for least-recently-used.

Actual:

import 'package:lru_cache/lru_cache.dart';

Future<void> main(List<String> args) async {
  final cache = LruCache<String, int>(2);

  cache.put('1', 1);
  cache.put('2', 2);

  await cache.get('1');
  cache.put('3', 3);

  print(cache.snapshot());
}

Output:
image

Expected:

import 'package:lru_cache/lru_cache.dart';

void main(List<String> args) {
  final cache = LruCache<String, int>(2);

  cache['1'] = 1;
  cache['2'] = 2;

  cache['1'];

  cache['3'] = 3;

  print(cache);
}

Output:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions