Reputation: 57
I am building a system that keeps track of many counters in real time in Redis. Each counter is basically the impression, conversion details for ad keywords shown on a specific url.
ie. if 10 keywords are shown on a specific url, I need to update a count for each of those keywords for both impressions and conversions. And on each impression of a url, possibly a different set of 10 keywords can be shown.
ie. the basic data model I need is something like
k1 => impression => 2 conversion => 1 k2 =><br> impression => 100 conversion => 8 . . k100 (max around 100)</li>
What is the best way to solve this problem?
I thought of combining k1-impression and k1 conversion and making it one single field
ie like
k1-impression => 100 k1-conversion => 3 .<br> . so on</li>
How would I go about solving this problem?
Any help will be appreciated.
Upvotes: 0
Views: 132
Reputation: 10893
If your keywords are of significant enough length that you're worried about it, you should normalize them. Make a hash of keyword -> id
, and a hash of id -> keyword
, for encoding and decoding them. Then you can have per-url hashes of the form url => {kw_id:impressions => 1123, kw_id:conversions => 28}
. This will also serve you well when you start needing to make indexes of the key words, which you will as soon as you get a requirement to show the top 10 best performing key words across all urls, for example.
Upvotes: 1