Ideal way for cron to loop through all users over several runs

chrisj

Active member
I have an expensive process that took 3 and a half minutes to do 184 users. I want to run over 3,000+ users every 24 hours at least. What is the best way to store my stopping point of the cron for the next time it is run?
 
Could use the simple cache:

http://xenforo.com/community/thread...o-add-datas-into-the-cache.30814/#post-352012

But the simple cache is loaded on every page so technically it's not appropriate for this.

You can also write your own registry record:

Rich (BB code):
// STORE DATA
XenForo_Model::create('XenForo_Model_DataRegistry')->set('yourKey', $value);

// RETRIEVE DATA
$value = XenForo_Model::create('XenForo_Model_DataRegistry')->get('yourKey');

// DELETE DATA (good for uninstall routines)
XenForo_Model::create('XenForo_Model_DataRegistry')->delete('yourKey');
 
Could use the simple cache:

What is the best way to add datas into the cache?

But the simple cache is loaded on every page so technically it's not appropriate for this.

You can also write your own registry record:

Rich (BB code):
// STORE DATA
XenForo_Model::create('XenForo_Model_DataRegistry')->set('yourKey', $value);

// RETRIEVE DATA
$value = XenForo_Model::create('XenForo_Model_DataRegistry')->get('yourKey');

// DELETE DATA (good for uninstall routines)
XenForo_Model::create('XenForo_Model_DataRegistry')->delete('yourKey');

Hey @Jake Bunce, I wan't to do something similar but with a little differences, I'm making a new custom user field like a Premium key, I already made the php code to generate unique key for each member, now there's 2 things I want to know, first I want to fill that field only to members who already in the Premium usergroup because I don't want to loop all members, then I want to generate the key and fill it into the field on members upgrade and truncate it on downgrade, is that possible?

One more thing, as I said I have the code to generate unique key for each members but I don't know if it's perfect, how can I prevent any duplication that might occur?

I though I could use the member ID and/or username to make a unique Key, also the key must be 16 or 20 chars.
 
Hey @Jake Bunce, I wan't to do something similar but with a little differences, I'm making a new custom user field like a Premium key, I already made the php code to generate unique key for each member, now there's 2 things I want to know, first I want to fill that field only to members who already in the Premium usergroup because I don't want to loop all members, then I want to generate the key and fill it into the field on members upgrade and truncate it on downgrade, is that possible?

One more thing, as I said I have the code to generate unique key for each members but I don't know if it's perfect, how can I prevent any duplication that might occur?

I though I could use the member ID and/or username to make a unique Key, also the key must be 16 or 20 chars.

I think this might be more relevant:

(Custom) SQL Query on User Upgrade

It's an old thread but the code should still be relevant to the latest version of XF (currently 1.5) maybe with a couple tweaks.
 
I think this might be more relevant:

(Custom) SQL Query on User Upgrade

It's an old thread but the code should still be relevant to the latest version of XF (currently 1.5) maybe with a couple tweaks.

What if I wanted to extend that function is that possible, I know a little about add-ons developing but I should to implement it, also what about the key generator, do you have any suggestion on how to prevent duplication?

Thank you for your time.
 
What if I wanted to extend that function is that possible, I know a little about add-ons developing but I should to implement it, also what about the key generator, do you have any suggestion on how to prevent duplication?

Thank you for your time.

I recommend posting a request if you aren't comfortable with addon development:

Resource and Add-on Requests
 
Top Bottom