nateware / redis-objects

Map Redis types directly to Ruby objects
Artistic License 2.0
2.09k stars 229 forks source link

Multitenant object conflict. #259

Closed abigoroth closed 2 years ago

abigoroth commented 3 years ago

My application is using apartment gem and I am using postgresql schema as its tenant. since the key is model_name:id:attribute I experience conflicts between tenants.

i've been eyeing on

https://github.com/nateware/redis-objects/blob/210041769d84ff5efc253d4075468de5e5653e27/lib/redis/objects.rb#L106-L112

maybe I can add something like @redis_prefix = "#{Apartment::Tenant.current}:#{@redis_prefix}" if Object.const_defined?(Apartment::Tenant.to_s) after https://github.com/nateware/redis-objects/blob/210041769d84ff5efc253d4075468de5e5653e27/lib/redis/objects.rb#L111

nateware commented 3 years ago

This was a bug I introduced into the original version, since I reused code from Sinatra that improperly removed the fully-qualified class name. Sorry. Unfortunately I don't know how to fix it at this point, as any change to that method would change the keyname, meaning that it would result in innumerable bugs accessing keys that were named using the original methodology.

If anyone has any great ideas, I'm all ears.

nateware commented 2 years ago

Duplicate of #231