Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_cache #10

Open
chimmel opened this issue Nov 16, 2016 · 1 comment
Open

get_cache #10

chimmel opened this issue Nov 16, 2016 · 1 comment

Comments

@chimmel
Copy link

chimmel commented Nov 16, 2016

How to utilize get_cache method? i.e., how to determine the particular cache file name/$fn argument?

@duzun
Copy link
Owner

duzun commented Nov 16, 2016

First of all I'd like to mention that hQuery::get_cache($fn, $expire=false, $meta_only=false) is a protected method, hence used internally only.

It could be used as a stand-alone method for purposes outside hQuery, but I have no intention to expose it as a public method for reading cache contents of hQuery.

If you want to make sure contents are fetched from cache (when there is contents in cache) just use a big enough $expires option:

$result = hQuery::fromURL('http://example.com', NULL, NULL, ['expires' => PHP_INT_MAX]);

You also have to set hQuery::$cache_path before using cache, otherwise, cache is disabled.
By default hQuery::$cache_expires is one hour (3600 sec), but you can change it at any point in your code.

I could add another method for checking whether a particular request is cached or not, something like: hQuery::isExpired($url, $opt=NULL).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants