Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Posts
    131
    Thanks
    21
    Thanked 0 Times in 0 Posts

    caching results to .txt files

    Hi,

    Im looking to dump some returned values into a txt file so that i can just go to that every 30-60sec instead or having the same thing requested over and over.

    The main reason i need this is because the data im pulling can only be given to me every few seconds, so if the page is refreshed within about 5sec then no results are returned and things look rather odd.

    Is there a specific way to write the values of $results into cache.txt ??
    php.net kindly offered cosh when looking for cache and i cant find anything via google or searching here unfortunately. I wouldnt have thought it was a big task, most of it would just be additional code to check whether to get live info or cached, but until i have it caching info im stuck.

    Thanks in advance,
    PaulC2K

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I learned how to write to a text file from here
    http://www.joe2torials.com/view_tutorial.php?view=61
    though storing the results in the text file could get rather large. What about using a database instead?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder
    Join Date
    Jul 2005
    Posts
    131
    Thanks
    21
    Thanked 0 Times in 0 Posts
    Thanks, i'll have a rummage through that

    txt files seem to be 'all the rage' really, in terms of doing this specific job, i suppose your right it could be db'd instead, hadnt thought of that!

    The text file would only be about 30k so its not something that would consume the site, is there likely to be any speed difference between pulling it from the .txt file and from the database, the site already does a fair bit of looking in there but if it would be quicker by .txt then thats the route i'd try for first.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    If you didn't mind anyone else viewing the text file then you could use it but if security was an issue I wouldn't recommend it.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    Regular Coder
    Join Date
    Jul 2005
    Posts
    131
    Thanks
    21
    Thanked 0 Times in 0 Posts
    nah, security isnt an issue here, its basically going through the official routes to get in-game information from the source. To avoid abuse they have a 4-5sec block between connections, and because the site this will go on tells you if the team members are online or not it previously went and asked the main server whenever the page was refreshed, so when flicking through a site you'd occasionallly get no results which usually means people tell me its not working sometimes.
    The cached file holds an array of server names and users in there, and then if there name is found then they're displayed as online.

    Anyway, just wanted to post and say I got it working and threaded into the original script. Took a little messing about to understand how to go about doing it, but it now works perfectly, checking at >15sec intervals though i'll probably switch that to >30sec once im done playing with a few other bits n peices.

    Thanks for pointing me in the right direction,
    PaulC2K


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •