php_text_cache php_text_cache(
[string
$cacheDir = './'], [int
$cacheTime = -1], [int
$timeout = 0]
)
|
|
Constructor
Parameters:
|
string |
$cacheDir: |
Directory in which to store the cache files |
|
int |
$cacheTime: |
Expiry time for cache file (-1 signifies no expiry limit) |
|
int |
$timeout: |
Time in seconds to disconnect after attempting an http connection |
void establishConnection(
string
$url
)
|
|
Establishes a connection, given an url
Parameters:
|
string |
$url: |
The url of the data |
string fromCache(
string
$cacheFile
)
|
|
Get text from cache file
Parameters:
|
string |
$cacheFile: |
The file path |
API Tags:
| Return: | The text contained in the file, or an empty string |
string fromFile(
string
$filename
)
|
|
Get text from an url or file
Parameters:
|
string |
$filename: |
The url or file path |
API Tags:
| Return: | The text contained in the url or file, or an empty string |
string fromURL(
string
$url, string
$cacheFile
)
|
|
Gets data from an url and caches a copy of the data
Parameters:
|
string |
$url: |
The url for the data |
|
string |
$cacheFile: |
The cache file path |
API Tags:
| Return: | The contents of the url |
string getCacheFileName(
string
$url
)
|
|
Given an url, returns the path to the cache file
Uses an md5 hash of the url. This can be overridden if a different approach is required
Parameters:
|
string |
$url: |
The url of the data |
API Tags:
| Return: | The cache file name |
string getData(
string
$url
)
|
|
Gets data from an url, or its cache file
Parameters:
|
string |
$url: |
The url of the data |
API Tags:
| Return: | The data at the specified url |
void setTimeout(
int
$timeout
)
|
|
Specifies the default timeout value for connecting to a host
Parameters:
|
int |
$timeout: |
The number of seconds to timeout when attempting to connect to a server |
void useHTTPClient(
boolean
$truthVal
)
|
|
Specifies whether an HTTP client should be used to establish a connection
Parameters:
|
boolean |
$truthVal: |
True if an HTTP client is to be used to establish the connection |