class SettingService {

    @Transactional
    public Map<String, String> getValues(long projectId) {
        // Lazy-loading of the cache (thread-safe with ConcurrentHashMap.computeIfAbsent and synchronizedMap())
        return projectsValuesCache.computeIfAbsent(projectId, key ->
                Collections.synchronizedMap(repository.getProjectSettings(projectId)));
    }

}