apache / apache/ignite

Automated Cache initialisation

Open
#11,451 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
5.1k
Forks
1.9k
Avg merge
3d 2h
Merged PRs (30d)
46

Description

I've been looking into using Ignite as an automated Caching layer on top of existing database table and I've just realised that it requires you to _MANUALLY_ call [LoadData](https://github.com/apache/ignite/) after startup.

The setup I'm looking into is pure helm/k8s deployment, so all the cache configurations, query entities, connections, etc. already exist and are operational, but it seems like it's impossible to configure it to automatically scrape the data from the datasource.

From my understanding Ignite already operates on top of Spring, so it should be possible to include some basic cache initialisation capabilities.

Very simple (autogenerated) piece of code that I would consider, is something like this?...
(Obviously it requires modifications inside related libraries, to actually properly pass the rest of configuration
(In my case, mainly `cacheStoreFactory` configs, that already provide the information on how to actually load the cache)

```
@Configuration
@EnableScheduling
public class CustomCacheConfiguration extends CacheConfiguration {

@IgniteInstanceResource
private Ignite ignite;

private String cronExpression;
private boolean initializeOnCreate;

public CustomCacheConfiguration(String name, String cronExpression, boolean initializeOnCreate) {
super(name);
this.cronExpression = cronExpression;
this.initializeOnCreate = initializeOnCreate;
}

@PostConstruct
public void postConstruct() {
if (initializeOnCreate) {
initializeCache();
}
}

@Scheduled(cron = "#{@customCacheConfiguration.cronExpression}")
public void scheduledInitializeCache() {
initializeCache();
}

public void initializeCache() {
IgniteCache cache = ignite.getOrCreateCache(this);
cache.loadCache(null);
}
}
```

initializeCache is also a method that could be easily exposed as part of RestAPI.

I'm not sure whether it's desired feature, but I believe it's something that would greatly increase the usability of Ignite in somewhat basic scenarios, especially with current shift into full k8s-based environments.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the existing LoadData and cache.loadCache behavior, then examine how cacheStoreFactory configuration is passed through the related libraries. Compare that with the Spring configuration and RestAPI integration mentioned in the issue; done would mean an agreed implementation for automatic, optional cache initialization and scheduling.

Written by the indexing model from the issue text.

Assessment

Tech stack
helm, java, kubernetes, spring
Domain
backend, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.