Skip to content

Commit a653fea

Browse files
committed
Make cache refresh configurable
Signed-off-by: Terence <terencelimxp@gmail.com>
1 parent 0ea7a5c commit a653fea

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

serving/src/main/java/feast/serving/config/FeastProperties.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ public void setCoreAuthentication(CoreAuthenticationProperties coreAuthenticatio
8686
this.coreAuthentication = coreAuthentication;
8787
}
8888

89+
/* Feast Core port to connect to. */
90+
@Positive private int coreCacheRefreshInterval;
91+
8992
private SecurityProperties security;
9093

9194
@Bean
@@ -220,6 +223,24 @@ public void setCoreGrpcPort(int coreGrpcPort) {
220223
this.coreGrpcPort = coreGrpcPort;
221224
}
222225

226+
/**
227+
* Gets CachedSpecService refresh interval.
228+
*
229+
* @return CachedSpecService refresh interval
230+
*/
231+
public int getCoreCacheRefreshInterval() {
232+
return coreCacheRefreshInterval;
233+
}
234+
235+
/**
236+
* Sets CachedSpecService refresh interval.
237+
*
238+
* @param coreCacheRefreshInterval CachedSpecService refresh interval
239+
*/
240+
public void setCoreCacheRefreshInterval(int coreCacheRefreshInterval) {
241+
this.coreCacheRefreshInterval = coreCacheRefreshInterval;
242+
}
243+
223244
/**
224245
* Sets the collection of configured stores.
225246
*

serving/src/main/java/feast/serving/config/SpecServiceConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ public class SpecServiceConfig {
3737
private static final Logger log = org.slf4j.LoggerFactory.getLogger(SpecServiceConfig.class);
3838
private String feastCoreHost;
3939
private int feastCorePort;
40-
private static final int CACHE_REFRESH_RATE_SECONDS = 10;
40+
private int CACHE_REFRESH_RATE_SECONDS;
4141

4242
@Autowired
4343
public SpecServiceConfig(FeastProperties feastProperties) {
4444
feastCoreHost = feastProperties.getCoreHost();
4545
feastCorePort = feastProperties.getCoreGrpcPort();
46+
CACHE_REFRESH_RATE_SECONDS = feastProperties.getCoreCacheRefreshInterval();
4647
}
4748

4849
@Bean

serving/src/main/resources/application.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ feast:
1717
audience: https://localhost #token audience.
1818
jwkEndpointURI: <jwkEndpointURI> #jwk enpoint uri, used for caching token till expiry.
1919

20+
core-cache-refresh-interval: 10
2021

2122
# Indicates the active store. Only a single store in the last can be active at one time. In the future this key
2223
# will be deprecated in order to allow multiple stores to be served from a single serving instance

serving/src/test/java/feast/serving/it/ServingServiceIT.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@
6060
import org.testcontainers.junit.jupiter.Testcontainers;
6161

6262
@ActiveProfiles("it")
63-
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
63+
@SpringBootTest(
64+
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
65+
properties = {
66+
"feast.core-cache-refresh-interval=1",
67+
})
6468
@Testcontainers
6569
public class ServingServiceIT extends BaseAuthIT {
6670

@@ -441,9 +445,9 @@ public void shouldReturnNotFoundForUpdatedType() {
441445
TestUtils.applyFeatureTable(
442446
coreClient, projectName, featureTableName, entities, features, 7200);
443447

444-
// Sleep is necessary to ensure caching (every 10s) of updated FeatureTable is done
448+
// Sleep is necessary to ensure caching (every 1s) of updated FeatureTable is done
445449
try {
446-
Thread.sleep(15000);
450+
Thread.sleep(2000);
447451
} catch (InterruptedException e) {
448452
}
449453

0 commit comments

Comments
 (0)