Save value of a scheduled task

Save value of a scheduled task

by saleh refaai -
Number of replies: 3

I am developing a plugin that works in a scheduled time (run each 12 hours). I am trying to read a value from the first row of a moodle table, then check if this value persists in the table for more than 12 hours then get a notification.  I don't want to create a table to save the timestamp and the value. 

How can I save the value for the next scheduled run and compare it with the current value to check if it is still the same value? 

Average of ratings: -
In reply to saleh refaai

Re: Save value of a scheduled task

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Can you use get_config / set_config?
In reply to Tim Hunt

Re: Save value of a scheduled task

by saleh refaai -
Thank you for your quick reply.

I can use the get_config / set_config but is it safe to use it just to save some value?
In reply to saleh refaai

Re: Save value of a scheduled task

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Yes, it will write it to the mdl_config_plugins table. As long as you save it against your plugin's name and a unique identifier within your plugin, it will not interfere with any other values.