Open GoogleCodeExporter opened 9 years ago
This can be done, but be aware that my cache system is very simple, and so can
respond only the same exact requests made previously.
For example, if you use getPosts() to get 20 photos, and then to get 5 photos,
the cache would not serve anything for the second request because the two
requests are different, even if the datas from the first could answer the
second. This kind of advanced caching would need to store informations from
Tumblr in a SQL database, and this is far beyond the scope of this class.
Anyway, I think I can make my class to use outdated cache files when Tumblr did
not respond.
Original comment by my.name....@gmail.com
on 15 Apr 2011 at 9:56
Okay, I made a first try, need testing now, so i'll wait to hear back from you
'cause I can't force a Tumblr downtime for real testing.
You can download it here : http://static.saymonz.net/phpTumblr0.7-dev.zip
This is really bleeding edge!
How it is supposed to work?
1) On initialization, we check for the existence of a '__TumblrDown' file in
the cache dir. If it's here and recent (created less than 10min ago), we use
only cache, even if some files are outdated.
2) If that file don't exist, we check the avilability of the Tumblelog we want
to read from. We assume that if the HTTP request don't end with HTTP 200 status
code, Tumblr is down. We create the '__TumblrDown' file and use only cache.
3) When the switch 'UseOutdated' is on, caching functions will not check for
the age of the files. We don't even try to reach Tumblr ('cause we would have
to wait for each HTTP request to expire, not really efficient). The outdated
files in the cache dir will not be erased as long as Tumblr stay down.
- When a getPosts() is totally or partially not in cache, getPosts returns
false, you can however have partial results (especially when using num all or
num > 50)
- If you request, for example, num = 20, start = 0 and then num = 20, start =
20, you may NOT have exactly 40 posts in your results if the cache files have
not been written at the same moment. But the 'stats' subarray hopefully don't
lie.
Original comment by my.name....@gmail.com
on 15 Apr 2011 at 11:24
I am sorry for taking so long on getting back to you on this. I am installing
this latest update on my blog right now. I will let it run for a bit and let
you know how it goes.
Original comment by joework...@gmail.com
on 12 May 2011 at 11:18
That's okay. Keep in mind that theses modifications are potentially buggy (I
have NOT tested, just checked for syntax errors).
Original comment by my.name....@gmail.com
on 12 May 2011 at 11:45
Original comment by my.name....@gmail.com
on 14 Jun 2012 at 1:02
Original issue reported on code.google.com by
joework...@gmail.com
on 15 Apr 2011 at 6:37