This topic contains 2 replies, has 0 voices, and was last updated by CREECE 7 years, 7 months ago.
-
AuthorPosts
-
April 6, 2017 at 3:28 pm #973
CREECEIf I have a map/reduce script that may run for a long time or the user starts at 10pm and it runs past midnight and my script relies on “today” still being the date it was started, what has anyone done to accomplish storing this value? Cache does me no good as you can’t rely on it being there Session variables do me no good as they don’t last from phase to phase.
The cache states when using get:
The maximum duration, in seconds, that a value retrieved by the loader can remain in the cache. Note that the value may be removed before the ttl limit is reached.
The default ttl value is no limit. The minimum value is 300 (five minutes).
Does this mean if I just store/retrieve a value NOT using the loader, that this value will remain for the life of the script? So far I have NOT ever seen a value not remain but i need some confirmation on this as the documentation is super vague.
The summary phase summary has a dateCreated property that tells me when the script begin running. The map and reduce phase do not.
This is a cached copy. Click here to see the original post. -
April 6, 2017 at 4:15 pm #974
david.smithWhy would you not be able to rely on the cache being there? The cache resided based on the scope you set. The TTL is just for the key when you get/set it. If you do not set the TTL the key/value should remain for the life of the cache, which you set by the scope.
CREECE replied on 04/06/2017, 07:55 PM: According to the doc, you are not promised the value will be there if you add a TTL. Why would it be there if you didn’t specify one? Either way you are setting a key in the cache. The documentation seems very vague to me about this. For example I could specify a TTL of 8 hours and it may or may not be there. If i don’t specify a value and my script runs for 8 hours what makes that any different? I’m just making sure there are no “gotchas” before I heavily rely on the cache.
-
April 7, 2017 at 7:24 pm #975
CREECEdavid.smith it won’t let me respond to your response but thank you. Since I am not specifying a TTL it should last for the entire script. I just made an extra method that gets called in the summary phase that removes the values I cached. Otherwise, I saw from multiple runs, that the values remain even if you change them since they are still cached. Thank for the assistance.
david.smith replied on 04/07/2017, 09:48 PM: No problem.
I found using the cache is a good way to track errors and status and then send out an email during the summary phase of a map/reduce.
-
AuthorPosts
You must be logged in to reply to this topic.