On Thu, Nov 1, 2012 at 4:28 PM, Josiah Carlson <
josiah....@gmail.com> wrote:
>> Which is more size efficient?
>> Which scales better?
>> Which is more logical?
>
> Do you ever want to time out your data? If so, you may want to
> structure your data such that you can have the data clean itself up
> with EXPIRE. Once you have answered that question, then you may want
> to consider that short hashes (up to 512 items by default) can use
> less space than the equivalent higher-level key. So maybe batch
> together a single day or week's worth of hourly data (depending on
> your expiration policy), one month's or one year's worth of daily data
> (depending on your expiration policy), and maybe keep all of your
> monthly/yearly data in a single hash for a given profile.
Agreed, so I would go for:
>> profile:visits:{{ID}}
>> YYYYMMDDHH
>> YYYYMMDD
>> YYYYMM
>> YYYY
>> total
YYYYMMDDHH -> hash key named YYYYMMDD, filed HH
YYYYMMDD -> hash with key named YYYYMM, field DD
YYYYMM -> hash with key named YYYY, field MM
YYYY -> hash with key named YYYY (so you reuse the previous hash),
field named "year_total"
total -> put this counter inside the user-specific hash directly to
avoid wasting a singel key for it.
In this way all the hashes should have less tha 512 fields, but you
may want to double check as I'm sleep deprived right now :-)
Cheers,
Salvatore
--
Salvatore 'antirez' Sanfilippo
open source developer - VMware
http://invece.org
Beauty is more important in computing than anywhere else in technology
because software is so complicated. Beauty is the ultimate defence
against complexity.
— David Gelernter