ente/lib/core/cache/thumbnail_cache.dart

28 lines
701 B
Dart
Raw Normal View History

import 'dart:typed_data';
2020-05-04 20:44:34 +00:00
import 'package:photos/core/cache/lru_map.dart';
import 'package:photos/core/constants.dart';
2020-06-19 23:03:26 +00:00
import 'package:photos/models/file.dart';
class ThumbnailLruCache {
2021-05-07 22:12:10 +00:00
static LRUMap<String, Uint8List> _map = LRUMap(1000);
static Uint8List get(File photo, [int size]) {
2021-05-07 22:12:10 +00:00
return _map.get(photo.generatedID.toString() +
"_" +
2021-07-21 20:47:43 +00:00
(size != null ? size.toString() : kThumbnailLargeSize.toString()));
}
static void put(
File photo,
Uint8List imageData, [
int size,
]) {
_map.put(
2021-05-07 22:12:10 +00:00
photo.generatedID.toString() +
"_" +
2021-07-21 20:47:43 +00:00
(size != null ? size.toString() : kThumbnailLargeSize.toString()),
2021-05-07 22:12:10 +00:00
imageData);
}
}