debop / hibernate-redis

hibernate 2nd level cache privder using redis
Apache License 2.0
357 stars 184 forks source link

Is it possible to configure redisson programmatically? #66

Closed GeBeater closed 7 years ago

GeBeater commented 8 years ago

Like the Redisson documentation linked below, Redisson can be configured programmatically or declarative. For my use case, it would be more flexible to use the programmatically way. So my question is, whether it is possible to use the dedop:hibernate-redis library together with the programmatically redisson configuration?

https://github.com/mrniko/redisson/wiki/2.-Configuration

debop commented 8 years ago

I can't find configure in promgramatic. hibernate instancing RegionFactory by configuration only. ( hibernate.cache.provider_configuration_file_resource_path )

johnou commented 7 years ago

@debop couldn't we allow the developer to extend SingletonRedisRegionFactory and provide a callback to configure Redisson?

debop commented 7 years ago

Ok, that's good idea. I try to implement callback for programmatic configuration and others.

johnou commented 7 years ago

For inspiration here is how Spring boot allows customising.

new EmbeddedServletContainerCustomizer() {

        @Override
        public void customize(ConfigurableEmbeddedServletContainer container) {
            if (container instanceof TomcatEmbeddedServletContainerFactory) {
                ((TomcatEmbeddedServletContainerFactory) container)
                        .addContextCustomizers(new TomcatContextCustomizer() {

                    @Override
                    public void customize(Context context) {
                        context.setCookieProcessor(new LegacyCookieProcessor());
                    }

                });
            }
        }

    };
johnou commented 7 years ago

@debop it's a good start, if you don't mind I would like to polish it a bit more.

johnou commented 7 years ago

There was an oversight in the implementation, fixed with https://github.com/debop/hibernate-redis/pull/74