debop / hibernate-redis

hibernate 2nd level cache privder using redis
Apache License 2.0
358 stars 182 forks source link

Implementation of a cache key customizer mecanism. #27

Closed dyorgio closed 8 years ago

dyorgio commented 10 years ago

Necessary to isolate second level and query caches in a multi-tenancy env.

ex:

return key + "#" + tenantId;
davidells commented 9 years ago

@debop This has been around for a year. Just found the need for the same functionality, and it looks good to us. Any chance this could be merged in?

peruzzo commented 9 years ago

+1

johnou commented 8 years ago

@bostanio we could pull this into our fork, looks useful, wdyt?

jonspalmer commented 8 years ago

@dyorgio, @davidells, @peruzzo what's the need here?

The full on key customizer seems like bit much. Would a simple key prefix be enough or is there some need for a suffix as well?

Also we need to be careful to get all instances of keys. I'm pretty sure the submitted fix doesn't capture the zsets that the plugin also uses and I bet that has some bad effects in a multi tenant situation. We also likely need tests to prove the correctness of the fix.

We'd be happy to consider a change to support this use case. We've forked the project here: https://github.com/hibernate-redis/hibernate-redis. If this is still of interest please create a PR there and we can discuss.

dyorgio commented 8 years ago

@bostanio This help me to isolate second lvl cache by tenant. I believe that the best implementation needs to use a different database by tenantId, but it will more hard to implement. Also hibernate-redis, in my option, is not ready for production. I did some modifications in a private repository(private company) to support expiration by key, than I could use it. I also have some doubts about using redis with second lvl cache, because I like to make cluster of my cache servers, ehcache is better to do it.

johnou commented 8 years ago

@dyorgio would you be willing to contribute your work for supporting expiration by key so you no longer need to maintain a third party library?

johnou commented 8 years ago

@debop does Reddison have anything built-in for this?

debop commented 8 years ago

@dyorgio , @johnou Redisson does not built-in for this. I will merge this code for multi-tenant env.

Thanks @dyorgio

debop commented 8 years ago

@dyorgio if you have test code, please send to me.

johnou commented 8 years ago

@debop @dyorgio looks like this could be achieved by using Environment.CACHE_REGION_PREFIX..?