feat: added total IO in the Network module when the app is started (#2087)

This commit is contained in:
Serhiy Mytrovtsiy
2024-09-07 17:41:10 +02:00
parent 16678796ab
commit 5e342553b2
4 changed files with 15 additions and 4 deletions

View File

@@ -74,7 +74,7 @@ public class DB {
}
}
public func insert(key: String, value: Codable, ts: Bool = true) {
public func insert(key: String, value: Codable, ts: Bool = true, force: Bool = false) {
self.values[key] = value
guard let blobData = try? JSONEncoder().encode(value) else { return }
@@ -82,7 +82,7 @@ public class DB {
self.lldb?.insert("\(key)@\(Date().currentTimeSeconds())", value: String(decoding: blobData, as: UTF8.self))
}
if let ts = self.writeTS[key], (Date().timeIntervalSince1970-ts.timeIntervalSince1970) < 30 { return }
if !force, let ts = self.writeTS[key], (Date().timeIntervalSince1970-ts.timeIntervalSince1970) < 30 { return }
self.lldb?.insert(key, value: String(decoding: blobData, as: UTF8.self))
self.writeTS[key] = Date()