Notes/src/public/app/services/note_attribute_cache.ts

25 lines
710 B
TypeScript
Raw Normal View History

2024-07-25 20:36:15 +03:00
import FAttribute from "../entities/fattribute.js";
/**
2023-05-05 23:41:11 +02:00
* The purpose of this class is to cache the list of attributes for notes.
*
2023-05-05 23:41:11 +02:00
* Cache invalidation granularity is global - whenever a write operation is detected to notes, branches or attributes,
* we invalidate the whole cache. That's OK, since the purpose for this is to speed up batch read-only operations, such
* as loading the tree which uses attributes heavily.
*/
class NoteAttributeCache {
2024-07-25 20:36:15 +03:00
attributes: Record<string, FAttribute[]>;
2025-01-09 18:07:02 +02:00
constructor() {
this.attributes = {};
}
invalidate() {
this.attributes = {};
}
}
const noteAttributeCache = new NoteAttributeCache();
2023-05-05 23:41:11 +02:00
export default noteAttributeCache;