HyperLogLogs take up 12KB of space. I don't see anything in the docs about when that storage is freed up.
My current plan is to call EXPIRE every time I call PFADD, but I can't find much discussion about expiring HLLs, so I'm wondering if I'm doing it wrong...
I'm planning on using HLLs to count the number of active visitors on my site in real-time. I only want to keep the counts for the past hour around, freeing up anything older than that.
NO, you cannot expire items added to the HLL. Instead, EXPIRE command will expire the whole HLL.
In order to achieve your goal, you can create HLL for each hour, and expire the whole HLL after some time.
// for the 2019082200
PFADD user:2019082200 user1
// also set expiration for the HLL, and expire it after 10 hours
EXPIRE user:2019082200 36000
// add more users
PFADD user:2019082200 user2
// until the next hour, create a new HLL for the next hour
PFADD user:2019082201 user1
EXPIRE user:2019082201 36000
Related
I know there are several ways to set a specific ttl for a key, but is there a way to add some extra time for a key which has a counting down ttl?
There's no built-in way to extend TTL. You need to get the current TTL, and then add some more TTL to it.
Wrap these two steps into a Lua script:
-- extend 300 seconds
eval 'local ttl = redis.call("TTL", "key") + 300; redis.call("EXPIRE", "key", ttl)' 0
Good question
there is no such command
I think it is a bad idea to have a command like that, you have to be careful when you use it.
Probably end up adding more time to the ttl than we expect. If you set it like 5 mins, the actual expire time will be close to 5 mins even if setting it multiple times in that request. But if you add multiple 5 mins to it, then we can`t be sure of the actual expire time
If I cache a payload, how long it will be valid?
There are 2 settings in caching-strategy;
Entry TTL and
Expiration Interval.
If I want to invalidate my cached value after 8 hours, How I should set above parameters?
What is the usage for 'invalidate cache' processor?
Entry TTL is how long an entry should live in the cache. Expiration interval is how frequently the object store will check the entries to see if one entry should be deleted. In your case entryTTL should 8 hours. Be mindful of the units used for each attribute. Expiration interval is a bit more tricky. You may want to check entries much more frequently to avoid them living more than 8 hours before expiring. It may be 10 minutes, 30 minutes, 1 hour or whatever works for you.
I explained it more in my blog: https://medium.com/#adobni/configuring-an-object-store-in-mule-4-5da609e3456a
Need to clear a concept about redis EXPIRE operation.
Imagine I write the following code:
HMSET myself name "Sam" age "21"
EXPIRE myself 60
This sets the hash myself={'name':'Sam','age':'21'} (using python dictionary to illustrate the concept). Moreover, it sets myself to expire after 60 seconds.
What happens to the EXPIRE setting if I perform a couple of operations on myself? E.g.:
HINCRBY myself age 1
HSET myself gender f
Will EXPIRE remain intact, or will it be removed? And taking it a step further, do us redis coders have any control on whether EXPIRE stays or not in such cases?
Expire will remain, and the TTL will continue to decrease.
From Redis doc :
altering the field value of a hash with HSET (...) will leave the timeout untouched
As Maurice Meyer said above, you can use TTL myself to get the remaining Time To Live of the key mysef, and so use it for your experiments.
Is there a way in Rails 3 to expire a field in the session? When I searched for this I only found posts about how to expire the whole session, which I do not want to do.
In my situation I have the following:
session["END_DATE"] = #end_date
I want to tell Rails to expire the field session["END_DATE"] after a certain amount of time, which is different and a lot less than the global expiry time for the whole session.
I can always use a cookie instead of a session for that field, but it would be good to have it in the session if it is possible.
you can do something like this:
session.delete(:end_date) to delete something(end_date in your case) from your session.
Hope it helps!
Is there any way to set limit in Loggly to take only last seven days logs information, other must be automatically deleted and than Loggly not be full because it will take only few days information.
Thanks
If you are using a free account, Loggly will automatically delete the data after 7 days. You should not worry about how much data is in storage, so long as your volume is under 200 MB per day. This is measured from 00:00h UTC.