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

Auto-caching existing StateRepository if enabled #164

Closed
norbson opened this issue Jun 17, 2016 · 5 comments
Closed

Auto-caching existing StateRepository if enabled #164

norbson opened this issue Jun 17, 2016 · 5 comments
Assignees
Milestone

Comments

@norbson
Copy link

@norbson norbson commented Jun 17, 2016

Current Autoconfiguration support automatic wrapping of StateRepository into CachingStateRepository only if there is no predefined StateRepository.

    @Configuration
    @ConditionalOnMissingBean(StateRepository.class)
    protected static class StateRepositoryConfiguration {
    //some code
            if (properties.getCache().isEnabled()) {
                stateRepository = new CachingStateRepository(stateRepository, properties.getCache().getTimeToLive(), properties.getCache().getTimeUnit());
            }
            return stateRepository;
        }
    }

Lets say that I defined JDBCStateRepository on my own and in the same time I set cache properties:

togglz:
      cache:
           enabled: true
           time-to-live: 10
           time-unit: seconds

I would expect that autoconfiguration wrap my stateRepository into cached one according to above properties.

Regards,
Norbert Krzysztofik

@marceloverdijk
Copy link

@marceloverdijk marceloverdijk commented Jun 17, 2016

Sounds like a fair use case, I hope to look into it this weekend.

Loading

@marceloverdijk
Copy link

@marceloverdijk marceloverdijk commented Jun 17, 2016

Loading

@norbson
Copy link
Author

@norbson norbson commented Jun 20, 2016

OK, scenarios which I went through

Given user defined StateRepository bean
And cache properties set to
"""
togglz:
    cache:
        enabled: true
        time-to-live: 60000
"""
When application boots
Then TogglzAutoConfiguration does wrap StateRepository bean into CachingStateRepository

Given user defined StateRepository bean
And cache properties set to
"""
togglz:
    cache:
        enabled: false        
        time-to-live: 60000
"""
When application boots
Then TogglzAutoConfiguration does not wrap StateRepository bean into CachingStateRepository

Given user defined StateRepository bean manually wrapped into CachingStateRepository
And cache properties set to
"""
togglz:
    cache:
        enabled: true
        time-to-live: 60000
"""
When application boots
Then TogglzAutoConfiguration does not wrap StateRepository bean into CachingStateRepository

Loading

@marceloverdijk
Copy link

@marceloverdijk marceloverdijk commented Jun 20, 2016

Great! Thx for the feedback. I will close the issue now. This will be part of 2.3.0 final release.

Loading

@norbson
Copy link
Author

@norbson norbson commented Jun 20, 2016

👍

Loading

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

Successfully merging a pull request may close this issue.

None yet
2 participants