Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
@@ -0,0 +1,40 @@
import Foundation
final class StoryTable: Table {
enum Event {
case updated(id: StoryId)
}
static func tableSpec(_ id: Int32) -> ValueBoxTable {
return ValueBoxTable(id: id, keyType: .binary, compactValuesOnCreation: false)
}
private let sharedKey = ValueBoxKey(length: 8 + 4)
private func key(_ key: StoryId) -> ValueBoxKey {
self.sharedKey.setInt64(0, value: key.peerId.toInt64())
self.sharedKey.setInt32(8, value: key.id)
return self.sharedKey
}
public func get(id: StoryId) -> CodableEntry? {
if let value = self.valueBox.get(self.table, key: self.key(id)) {
return CodableEntry(data: value.makeData())
} else {
return nil
}
}
public func set(id: StoryId, value: CodableEntry, events: inout [Event]) {
if self.get(id: id) != value {
self.valueBox.set(self.table, key: self.key(id), value: MemoryBuffer(data: value.data))
events.append(.updated(id: id))
}
}
override func clearMemoryCache() {
}
override func beforeCommit() {
}
}