Skip to content

Commit a068c1c

Browse files
Adding explicit cacheNames for all @Cacheable and @CacheEvict declarations (#644)
* Adding explicit cacheNames for all @Cacheable and @CacheEvict declerations to fix a potential issue with caching in SBN3 not enabled without explicit definition * Fixing Checkstyles
1 parent c5c7136 commit a068c1c

File tree

5 files changed

+39
-17
lines changed

5 files changed

+39
-17
lines changed

metacat-connector-hive/src/main/java/com/netflix/metacat/connector/hive/commonview/CommonViewHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public boolean update(final TableInfo tableInfo) {
9797
* @param tableInfo table info
9898
* @param tableMetadataLocation the common view table metadata location.
9999
*/
100-
@CacheEvict(key = "'iceberg.view.' + #tableMetadataLocation", beforeInvocation = true)
100+
@CacheEvict(cacheNames = "metacat", key = "'iceberg.view.' + #tableMetadataLocation", beforeInvocation = true)
101101
public void handleUpdate(final ConnectorRequestContext requestContext,
102102
final DirectSqlTable directSqlTable,
103103
final TableInfo tableInfo,

metacat-connector-hive/src/main/java/com/netflix/metacat/connector/hive/iceberg/IcebergTableOpsProxy.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ public class IcebergTableOpsProxy {
1515
* @param useCache true, if table can be retrieved from cache
1616
* @return TableMetadata
1717
*/
18-
@Cacheable(key = "'iceberg.' + #icebergTableOps.currentMetadataLocation()", condition = "#useCache")
18+
@Cacheable(
19+
cacheNames = "metacat",
20+
key = "'iceberg.' + #icebergTableOps.currentMetadataLocation()",
21+
condition = "#useCache"
22+
)
1923
public TableMetadata getMetadata(final IcebergTableOps icebergTableOps, final boolean useCache) {
2024
return icebergTableOps.refresh();
2125
}

metacat-connector-hive/src/main/java/com/netflix/metacat/connector/hive/sql/HiveConnectorFastTableServiceProxy.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ public HiveConnectorFastTableServiceProxy(
6161
* @param useCache true, if table can be retrieved from cache
6262
* @return TableInfo
6363
*/
64-
@Cacheable(key = "'iceberg.table.' + #includeInfoDetails + '.' + #tableMetadataLocation", condition = "#useCache")
64+
@Cacheable(
65+
cacheNames = "metacat",
66+
key = "'iceberg.table.' + #includeInfoDetails + '.' + #tableMetadataLocation",
67+
condition = "#useCache"
68+
)
6569
public TableInfo getIcebergTable(final QualifiedName tableName,
6670
final String tableMetadataLocation,
6771
final TableInfo info,
@@ -83,7 +87,7 @@ public TableInfo getIcebergTable(final QualifiedName tableName,
8387
* @param useCache true, if table can be retrieved from cache
8488
* @return TableInfo
8589
*/
86-
@Cacheable(key = "'iceberg.view.' + #tableMetadataLocation", condition = "#useCache")
90+
@Cacheable(cacheNames = "metacat", key = "'iceberg.view.' + #tableMetadataLocation", condition = "#useCache")
8791
public TableInfo getCommonViewTableInfo(final QualifiedName name,
8892
final String tableMetadataLocation,
8993
final TableInfo info,

metacat-connector-polaris/src/main/java/com/netflix/metacat/connector/polaris/PolarisConnectorTableService.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import lombok.extern.slf4j.Slf4j;
3131
import org.apache.commons.collections.MapUtils;
3232
import org.apache.commons.lang3.StringUtils;
33+
import org.springframework.cache.annotation.CacheConfig;
3334
import org.springframework.cache.annotation.Cacheable;
3435
import org.springframework.dao.DataIntegrityViolationException;
3536

@@ -45,6 +46,7 @@
4546
* table service for polaris connector.
4647
*/
4748
@Slf4j
49+
@CacheConfig(cacheNames = "metacat")
4850
public class PolarisConnectorTableService implements ConnectorTableService {
4951
protected final PolarisStoreService polarisStoreService;
5052
protected final PolarisConnectorDatabaseService polarisConnectorDatabaseService;
@@ -365,7 +367,11 @@ public List<TableInfo> list(
365367
* @param useCache true, if table can be retrieved from cache
366368
* @return TableInfo
367369
*/
368-
@Cacheable(key = "'iceberg.table.' + #includeInfoDetails + '.' + #tableMetadataLocation", condition = "#useCache")
370+
@Cacheable(
371+
cacheNames = "metacat",
372+
key = "'iceberg.table.' + #includeInfoDetails + '.' + #tableMetadataLocation",
373+
condition = "#useCache"
374+
)
369375
public TableInfo getIcebergTable(final QualifiedName tableName,
370376
final String tableMetadataLocation,
371377
final TableInfo info,

metacat-main/src/main/java/com/netflix/metacat/main/services/impl/ConnectorTableServiceProxy.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ public void create(final QualifiedName name, final TableInfo tableInfo) {
7979
* @param name table name
8080
*/
8181
@Caching(evict = {
82-
@CacheEvict(key = "'table.' + #name", beforeInvocation = true),
83-
@CacheEvict(key = "'table.includeInfoDetails.' + #name", beforeInvocation = true),
84-
@CacheEvict(key = "'table.metadataLocationOnly.' + #name", beforeInvocation = true)
82+
@CacheEvict(cacheNames = "metacat", key = "'table.' + #name", beforeInvocation = true),
83+
@CacheEvict(cacheNames = "metacat", key = "'table.includeInfoDetails.' + #name", beforeInvocation = true),
84+
@CacheEvict(cacheNames = "metacat", key = "'table.metadataLocationOnly.' + #name", beforeInvocation = true)
8585
})
8686
public void delete(final QualifiedName name) {
8787
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
@@ -100,7 +100,7 @@ public void delete(final QualifiedName name) {
100100
* @param useCache true, if the location can be retrieved from the cache
101101
* @return The table info object with the metadata location.
102102
*/
103-
@Cacheable(key = "'table.metadataLocationOnly.' + #name", condition = "#useCache")
103+
@Cacheable(cacheNames = "metacat", key = "'table.metadataLocationOnly.' + #name", condition = "#useCache")
104104
public TableInfo getWithMetadataLocationOnly(final QualifiedName name,
105105
final GetTableServiceParameters getTableServiceParameters,
106106
final boolean useCache) {
@@ -115,7 +115,7 @@ public TableInfo getWithMetadataLocationOnly(final QualifiedName name,
115115
* @param useCache true, if the location can be retrieved from the cache
116116
* @return The table info object
117117
*/
118-
@Cacheable(key = "'table.includeInfoDetails.' + #name", condition = "#useCache")
118+
@Cacheable(cacheNames = "metacat", key = "'table.includeInfoDetails.' + #name", condition = "#useCache")
119119
public TableInfo getWithInfoDetails(final QualifiedName name,
120120
final GetTableServiceParameters getTableServiceParameters,
121121
final boolean useCache) {
@@ -131,7 +131,7 @@ public TableInfo getWithInfoDetails(final QualifiedName name,
131131
* @param useCache true, if table can be retrieved from cache
132132
* @return table dto
133133
*/
134-
@Cacheable(key = "'table.' + #name", condition = "#useCache")
134+
@Cacheable(cacheNames = "metacat", key = "'table.' + #name", condition = "#useCache")
135135
public TableInfo get(final QualifiedName name,
136136
final GetTableServiceParameters getTableServiceParameters,
137137
final boolean useCache) {
@@ -162,9 +162,17 @@ private TableInfo getInternal(final QualifiedName name,
162162
* @param isMView true, if the object is a view
163163
*/
164164
@Caching(evict = {
165-
@CacheEvict(key = "'table.' + #oldName", beforeInvocation = true),
166-
@CacheEvict(key = "'table.includeInfoDetails.' + #oldName", beforeInvocation = true),
167-
@CacheEvict(key = "'table.metadataLocationOnly.' + #oldName", beforeInvocation = true)
165+
@CacheEvict(cacheNames = "metacat", key = "'table.' + #oldName", beforeInvocation = true),
166+
@CacheEvict(
167+
cacheNames = "metacat",
168+
key = "'table.includeInfoDetails.' + #oldName",
169+
beforeInvocation = true
170+
),
171+
@CacheEvict(
172+
cacheNames = "metacat",
173+
key = "'table.metadataLocationOnly.' + #oldName",
174+
beforeInvocation = true
175+
)
168176
})
169177
public void rename(
170178
final QualifiedName oldName,
@@ -190,9 +198,9 @@ public void rename(
190198
* @return true if errors after this should be ignored.
191199
*/
192200
@Caching(evict = {
193-
@CacheEvict(key = "'table.' + #name", beforeInvocation = true),
194-
@CacheEvict(key = "'table.includeInfoDetails.' + #name", beforeInvocation = true),
195-
@CacheEvict(key = "'table.metadataLocationOnly.' + #name", beforeInvocation = true)
201+
@CacheEvict(cacheNames = "metacat", key = "'table.' + #name", beforeInvocation = true),
202+
@CacheEvict(cacheNames = "metacat", key = "'table.includeInfoDetails.' + #name", beforeInvocation = true),
203+
@CacheEvict(cacheNames = "metacat", key = "'table.metadataLocationOnly.' + #name", beforeInvocation = true)
196204
})
197205
public boolean update(final QualifiedName name, final TableInfo tableInfo) {
198206
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();

0 commit comments

Comments
 (0)