Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncCacheResolver could not be found, with multiple caches caffeine #319

Open
amirdikhanbayev opened this issue Jul 19, 2024 · 1 comment

Comments

@amirdikhanbayev
Copy link

@Bean
    @Primary
    public SyncCacheResolver bucket4jCacheResolver() {
        final CachingProvider cachingProvider = Caching.getCachingProvider();
        CaffeineConfiguration<Object, Object> configuration = new CaffeineConfiguration<>();
        configuration.setExpireAfterWrite(OptionalLong.of(Duration.ofHours(1).toNanos()));
        configuration.setMaximumSize(OptionalLong.of(1000000));
        CacheManager cacheManager = cachingProvider.getCacheManager();
        cacheManager.createCache("rateLimiting", configuration);
        return new JCacheCacheResolver(cacheManager);
    }

Hello! After implementing this config still have ChacheResolver exception

Description:

Parameter 2 of constructor in com.giffing.bucket4j.spring.boot.starter.Bucket4jStartupCheckConfiguration required a bean of type 'com.giffing.bucket4j.spring.boot.starter.config.cache.AsyncCacheResolver' that could not be found.

Action:

Consider defining a bean of type 'com.giffing.bucket4j.spring.boot.starter.config.cache.AsyncCacheResolver' in your configuration.

@amirdikhanbayev
Copy link
Author

UPD:

Okey like i saw JCacheCacheResolver doesn't implement AsyncCacheResolver

public class JCacheCacheResolver extends AbstractCacheResolverTemplate<String> implements SyncCacheResolver {
    private final CacheManager cacheManager;

    public JCacheCacheResolver(CacheManager cacheManager) {
        this.cacheManager = cacheManager;
    }

    public String castStringToCacheKey(String key) {
        return key;
    }

    public boolean isAsync() {
        return false;
    }

Is it will support late? Or we have other way to config without AsyncCacheResolver?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant