fn sweepOf
Applies the retention of the topic now (@retain(...)) and returns the number of elements removed. The generated T.sweep() calls it.
Example:
data Job { id: i64 }
@retain(count: 2)
topic Jobs: Job
cluster demo {
role store { journal }
}
fn main() -> () | TopicError io, db {
var i: i64 = 0
while i < 5 {
Jobs.publish(Job{ id: i })?
i += 1
}
Jobs.sweep()?
print("{Jobs.count()?}")
}Вывод
2
pub(api) fn sweepOf(h: i64) -> i64 | TopicError dbСложность. O(removed elements).
С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
h | i64 |
Возвращает
i64
Ошибки
TopicError@error- `TopicError` when the store is not reachable.
Эффекты
db
Определено в: std/topic/topic.oxl:483