Optimize Redis Object storage by store object permissions differently
Currently the whole object needs to be read in order to check the permissions and e.g. to delete the object :-)
We should think about other ways to store permissions (redis bit operations and storing permissions as numbers?) beside object
But additionally having permissions in objects itself for backward compatibility we could then keep objects and the permissions in sync via multi exec watch
BITFIELDSwould work. e.g. BITFIELD test SET u16 #0 1638 or even u11 would be enough, because maximum would be hex 777 -> bin 11101110111 -> dec 1911 and to get BITFIELD test GET #0 u16.
Then another "problem" is, that we also need to store owner and group somwhow. See
{"object":1636,"state":1638,"owner":"system.user.admin","ownerGroup":"system.group.administrator"}
and keep changing permissions atomic or only use the new (bitfield style) acl everywhere.
We could use the object namespace with the prefix p so cfg.p. on default, we can also use a single entry with the id containing 11 bits for the permissions, followed by owner and ownerGroup spearated by a comma or any value which is not allowed in user and group names. Then using bitfields combined with ranges or just get/set.
127.0.0.1:6379> del test
(integer) 1
127.0.0.1:6379> BITFIELD test SET u11 0 1638
1) (integer) 0
127.0.0.1:6379> SETRANGE test 11 admin,bla
(integer) 20
127.0.0.1:6379> BITFIELD test GET u11 0
1) (integer) 1638
127.0.0.1:6379> GETRANGE test 11 -1
"admin,bla"
127.0.0.1:6379> get test
"\xcc\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00admin,bla"