Handle low memory notification.

This commit is contained in:
Brent Simmons committed 2026-03-07 17:07:52 -08:00
1 parent 2d5829f934
commit d2d85a83e5
1 file changed
+6
@@ -43,6 +43,8 @@ final class ArticlesTable: DatabaseTable, Sendable {
self.searchTable = SearchTable(queue: queue)
self.searchTable.articlesTable = self
NotificationCenter.default.addObserver(self, selector: #selector(handleLowMemory(_:)), name: .lowMemory, object: nil)
}
// MARK: - Fetching Articles for Feed
@@ -588,6 +590,10 @@ final class ArticlesTable: DatabaseTable, Sendable {
// MARK: - Caches
@objc func handleLowMemory(_ notification: Notification) {
emptyCaches()
}
func emptyCaches() {
queue.runInDatabase { _ in
self.articlesCache.withLock { $0 = [String: Article]() }