1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'XenForo Development Discussions' started by chrisj, Jul 8, 2012.

  1. chrisj

    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?
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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:

    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');
    
     
    Steve F, 0xym0r0n and chrisj like this.
  3. Cyb3r

    Cyb3r Well-Known Member

    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.
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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.
     
  5. Cyb3r

    Cyb3r Well-Known Member

    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.
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

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

    Resource and Add-on Requests
     
  7. Cyb3r

    Cyb3r Well-Known Member

    I didn't say that bud, I'd rather to do it myself I was just consulting you which way is the best to prevent any unwanted duplications for the key, but yeah thank you for your time anyway man. (y)
     

Share This Page