📄 src/Graph/FolderChildrenCache.cs
using NotesApp.Models;

namespace NotesApp.Graph;

// In-memory only, process-lifetime cache of folder id -> its child folders. Lets the folder
// picker render a level instantly if it was already fetched (either from a prior visit, or
// pre-warmed while browsing the parent level), instead of waiting on a network call on every
// tap. No TTL/invalidation: folder structure rarely changes mid-setup, and the cache is gone
// the moment the process dies.
public static class FolderChildrenCache
{
    private static readonly Dictionary<string, List<DriveFolderItem>> Cache = [];

    public static bool TryGet(string folderKey, out List<DriveFolderItem> children) =>
        Cache.TryGetValue(folderKey, out children!);

    public static void Set(string folderKey, List<DriveFolderItem> children) =>
        Cache[folderKey] = children;
}