`dictEvict` or `dictExpire` command for cached dictionaries.
#41,007 建立於 2022年9月5日
倉庫指標
- 星標
- (47,419 顆星)
- PR 合併指標
- (平均合併 2天 2小時) (30 天內合併 1,000 個 PR)
描述
Use case
We have a moderately sized reference dataset that we reference in Clickhouse queries, that fits comfortably in memory. A small portion of the dataset is updated every second.
We have a stream of change data capture data with the keys that are updated that's processed by our ingestion service (a Kafka consumer application, not part of Clickhouse).
We would like to be able to create a dictionary with LAYOUT(CACHE) and a very long TTL, and evict or expire keys manually based on the stream of changes we receive. This would allow most keys, which are not getting updated, to remain in memory, but also allow the keys that have been modified to be reloaded, while keeping the dictionary updates to a minimum.
Describe the solution you'd like
A dictExpire('dict_name', id_expr) function that expires or evicts the key that's passed as argument. This would allow our process to invalidate the cache keys it has just updated.
For our use case we don't need the eviction to take effect immediately after the statement, as long as we can configure the upper bound for the eviction to take place. In that scenario dictExpire conveys the idea that the key might be removed asynchronously, if the eviction were to by synchronous, then dictEvict would be a better name I think.
Describe alternatives you've considered
We've tried several dictionary backends with LAYOUT(DIRECT) but the in memory cache is incredibly fast and nothing even gets close. For our solution we need the in-memory cache.
We looked at memory tables but it's not optimized for key value lookup.