Skip to content

Commit

Permalink
feat(cubestore): Implement CACHE REMOVE
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Sep 14, 2022
1 parent 16e903b commit abade08
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions rust/cubestore/cubestore/src/metastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down
2 changes: 1 addition & 1 deletion rust/cubestore/cubestore/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![])))
}
Expand Down

0 comments on commit abade08

Please sign in to comment.