Skip to content

Cache

Daniel Garcia Moreno requested to merge danigm/fractal:cache into master

This MR replaces the current json file cache with the mdl "lmdb" database cache.

This first change defines almost all the internals needed to manage the cache in the fractal-gtk, but I've tried to maintain the diff minimal, replacing only the cache store and load functions.

With this simple change we can get the list of rooms in the cache easily with the FCache object. What I've in mind is to replace any access to AppOp.rooms with a call to the FCache, get_room, get_rooms, save_room, etc. And do the same for other AppOp attributes, moving that to the AppState struct that can be get using FCache.get_st.

I've defined FCache as a singleton, it's an static ref and you can get a copy using the cache::get function. So for example we can use this code in any thread:

use self::cache;

let mut room = cache::get().get_room(roomid)?;
room.name = Some("New name");
cache::get().save_room(room);

That code will get the room from the cache, and then update it and store again in the cache so next calls to the get_room will give us the new room with the new name.

Edited by Daniel Garcia Moreno

Merge request reports