From abade08ac3a361c11d4631f57ed27de40c2b51a1 Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Wed, 14 Sep 2022 18:39:53 +0300 Subject: [PATCH] feat(cubestore): Implement CACHE REMOVE --- rust/cubestore/cubestore/src/metastore/mod.rs | 15 +++++++++++++-- rust/cubestore/cubestore/src/sql/mod.rs | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/rust/cubestore/cubestore/src/metastore/mod.rs b/rust/cubestore/cubestore/src/metastore/mod.rs index 4ae884e5214ef..8d62950bd6899 100644 --- a/rust/cubestore/cubestore/src/metastore/mod.rs +++ b/rust/cubestore/cubestore/src/metastore/mod.rs @@ -3722,8 +3722,19 @@ impl MetaStore for RocksMetaStore { } async fn cache_delete(&self, key: String) -> Result<(), CubeError> { - self.write_operation(move |db_ref, batch_pipe| Ok(())) - .await?; + self.write_operation(move |db_ref, batch_pipe| { + let cache_schema = CacheItemRocksTable::new(db_ref.clone()); + let index_key = CacheItemIndexKey::ByKey(key); + let row_opt = + cache_schema.get_single_opt_row_by_index(&index_key, &CacheItemRocksIndex::Key)?; + + if let Some(row) = row_opt { + cache_schema.delete(row.id, batch_pipe)?; + } + + Ok(()) + }) + .await?; Ok(()) } diff --git a/rust/cubestore/cubestore/src/sql/mod.rs b/rust/cubestore/cubestore/src/sql/mod.rs index 31c130f53255d..700b7120f3ae3 100644 --- a/rust/cubestore/cubestore/src/sql/mod.rs +++ b/rust/cubestore/cubestore/src/sql/mod.rs @@ -1086,7 +1086,7 @@ impl SqlService for SqlServiceImpl { } } CubeStoreStatement::CacheRemove { key } => { - let key = key.value; + self.db.cache_delete(key.value).await?; Ok(Arc::new(DataFrame::new(vec![], vec![]))) }