ntalbott/relix — Issue #6: current_values redis hash unnecessarily contains primary key
Author: myronmarston
Created: 2012-01-06 05:11:17+00:00
State: open

I noticed that the current\_values redis hash contains an entry for the primary key...but the primary key is part of the redis key for the hash itself. So it's redundant and a waste of redis memory.

I think we can safely remove it from the hash, but I may be missing something.

Also, I have an extra unique index keyed on the primary key and ordered by another attribute (a date).

``` ruby
relix do
unique :ordered_by_date, on: :key, order: :date
end
```

In this case, there are 2 extra copies of the primary key in the hash:

```
Relix.redis.hgetall "MyModel:v:the-primary-key"
=> {"key"=>"the-primary-key", "date"=>"2011-10-07", "ordered_by_date"=>"the-primary-key"}
```

Again, I think we can do without that value.

Taking this even further: if we're only indexing a model on its primary key, can we get away with not storing a current values hash?