@@ -34,10 +34,6 @@ public boolean supportsCache(String cacheName) {
34
34
35
35
@ Override
36
36
public boolean match (String cacheName , Object key ) {
37
- if (!SUPPORTED_CACHE_NAMES .contains (cacheName )) {
38
- return false ;
39
- }
40
-
41
37
switch (cacheName ) {
42
38
case ENTITY_SEARCH_SERVICE_SEARCH_CACHE_NAME :
43
39
return matchSearchServiceCacheKey (key );
@@ -48,8 +44,9 @@ public boolean match(String cacheName, Object key) {
48
44
}
49
45
50
46
private boolean matchSearchServiceScrollCacheKey (Object key ) {
51
- Octet <?, List <String >, String , String , ?, ?, List <String >, ?> cacheKey
52
- = (Octet <?, List <String >, String , String , ?, ?, List <String >, ?>) key ;
47
+ Octet <?, List <String >, String , String , ?, ?, List <String >, ?> cacheKey =
48
+ (Octet <?, List <String >, String , String , ?, ?, List <String >, ?>) key ;
49
+ // For reference - cache key contents
53
50
// @Nonnull OperationContext opContext,
54
51
// @Nonnull List<String> entities,
55
52
// @Nonnull String query,
@@ -63,34 +60,52 @@ private boolean matchSearchServiceScrollCacheKey(Object key) {
63
60
String query = (String ) cacheKey .getValue (2 );
64
61
List <String > facets = (List <String >) cacheKey .getValue (6 );
65
62
66
- //Facets may contain urns. Since the check for urns in filters is similar, can append it to the filter.
67
- return isKeyImpactedByEntity (entitiesInCacheKey , query , filter + " " + String .join (" " ,facets ));
63
+ if (filter == null ) {
64
+ filter = "" ;
65
+ }
66
+ filter += " " + String .join (" " , facets );
67
+ // Facets may contain urns. Since the check for urns in filters is similar, can append it to the
68
+ // filter.
69
+ return isKeyImpactedByEntity (entitiesInCacheKey , query , filter );
68
70
}
69
71
70
72
private boolean matchSearchServiceCacheKey (Object key ) {
71
73
Septet <?, List <String >, ?, String , ?, ?, ?> cacheKey =
72
74
(Septet <?, List <String >, ?, String , ?, ?, ?>) key ;
75
+ // For reference
76
+ // @Nonnull OperationContext opContext,
77
+ // @Nonnull List<String> entityNames,
78
+ // @Nonnull String query,
79
+ // @Nullable Filter filters,
80
+ // List<SortCriterion> sortCriteria,
81
+ // @Nonnull List<String> facets
82
+ // querySize
73
83
74
84
List <String > entitiesInCacheKey = (List <String >) cacheKey .getValue (1 );
75
85
String filter = (String ) cacheKey .getValue (3 );
76
86
String query = (String ) cacheKey .getValue (2 );
87
+ List <String > facets = (List <String >) cacheKey .getValue (5 );
88
+
89
+ // Facets may contain urns. Since the check for urns in filters is similar, can append it to the
90
+ // filter.
91
+ if (filter == null ) {
92
+ filter = "" ;
93
+ }
94
+ filter += " " + String .join (" " , facets );
77
95
78
96
return isKeyImpactedByEntity (entitiesInCacheKey , query , filter );
79
97
}
80
98
81
- boolean isKeyImpactedByEntity (List <String > entitiesInCacheKey , String query , String filter ){
99
+ boolean isKeyImpactedByEntity (List <String > entitiesInCacheKey , String query , String filter ) {
82
100
boolean entityMatch = entitiesInCacheKey .stream ().anyMatch (entityTypes ::contains );
83
101
if (!entityMatch ) {
84
102
return false ;
85
103
}
86
104
87
- if (filter == null ){ //No filter, but already established there is an entity match
88
- return true ;
89
- }
90
-
91
- // Ignoring query for now. A query could make this cache entry more targeted, but till there is a quick way to
92
- // evaluate if the entities that were updated are affected by this query, ignoring it may mean some cache entries
93
- // are invalidated even if they may not be a match, and an uncached query result will still be fetched.
105
+ // Ignoring query for now. A query could make this cache entry more targeted, but till there is
106
+ // a quick way to evaluate if the entities that were updated are affected by this query,
107
+ // ignoring it may mean some cache entries are invalidated even if they may not be a match,
108
+ // and an uncached query result will still be fetched.
94
109
95
110
boolean containsUrn = filter .contains ("urn:li" );
96
111
if (!containsUrn ) {
0 commit comments