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

22 lines
667 B
JavaScript
Raw Normal View History

/**
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 {
constructor() {
2023-05-05 23:41:11 +02:00
/** @property {Object.<string, BAttribute[]>} */
this.attributes = {};
}
invalidate() {
this.attributes = {};
}
}
const noteAttributeCache = new NoteAttributeCache();
2023-05-05 23:41:11 +02:00
export default noteAttributeCache;