Reputation: 1000
In my api, I'd like to run a rake task every 10 minutes(for instance at 8:00, 8:10..). This task can take up to 10 minutes to execute(Thus, the next task can start its execution before the first one ends). Since this task executes a lot of time-consuming queries at the beginning, I thought about splitting my rake task to two:
I was wondering if there is way a to store the result of the first rake task and use it in the second one? Or, is there another way to do what I am planing to build?
FYI, I don't want to use database storage since writing/reading takes a lot of time.
Upvotes: 0
Views: 449
Reputation: 239511
This makes no sense on the face of it. If your second task is dependent on your first, and your first only prepares data for the second, you either need to store the data in the database, or (more sensibly) just make it one task. Whatever other non-database storage solutions you come up with aren't going to be any better than a database.
If you need it to be two tasks, then modularlize things. Use three tasks; the first two can be run independently, and the third will invoke the first and pass the result to the second.
Upvotes: 2
Reputation: 1
Use database tables or memcache/redis for storing the results.
for example, create a table called cached_results
(don't use this name, use a name which is closer to your business logic) and store the results with a timestamp. Or similarly you can use memcache/redis with some sort of ttl
Upvotes: 0