mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-06-25 20:34:22 +02:00
fix: rewrite and improve caching (#3594)
This commit is contained in:
@ -5,10 +5,12 @@ The `getInput` function is used to receive a value for a parameter, specified in
|
||||
$this->getInput('your input name here');
|
||||
```
|
||||
|
||||
`getInput` will either return the value for your parameter or `null` if the parameter is unknown or not specified.
|
||||
`getInput` will either return the value for your parameter
|
||||
or `null` if the parameter is unknown or not specified.
|
||||
|
||||
# getKey
|
||||
The `getKey` function is used to receive the key name to a selected list value given the name of the list, specified in `const PARAMETERS`
|
||||
The `getKey` function is used to receive the key name to a selected list
|
||||
value given the name of the list, specified in `const PARAMETERS`
|
||||
Is able to work with multidimensional list arrays.
|
||||
|
||||
```PHP
|
||||
@ -34,7 +36,8 @@ $this->getKey('country');
|
||||
// if the selected value was "ve", this function will return "Venezuela"
|
||||
```
|
||||
|
||||
`getKey` will either return the key name for your parameter or `null` if the parameter is unknown or not specified.
|
||||
`getKey` will either return the key name for your parameter or `null` if the parameter
|
||||
is unknown or not specified.
|
||||
|
||||
# getContents
|
||||
The `getContents` function uses [cURL](https://secure.php.net/manual/en/book.curl.php) to acquire data from the specified URI while respecting the various settings defined at a global level by RSS-Bridge (i.e., proxy host, user agent, etc.). This function accepts a few parameters:
|
||||
@ -53,33 +56,29 @@ $html = getContents($url, $header, $opts);
|
||||
```
|
||||
|
||||
# getSimpleHTMLDOM
|
||||
The `getSimpleHTMLDOM` function is a wrapper for the [simple_html_dom](https://simplehtmldom.sourceforge.io/) [file_get_html](https://simplehtmldom.sourceforge.io/docs/1.9/api/file_get_html/) function in order to provide context by design.
|
||||
The `getSimpleHTMLDOM` function is a wrapper for the
|
||||
[simple_html_dom](https://simplehtmldom.sourceforge.io/) [file_get_html](https://simplehtmldom.sourceforge.io/docs/1.9/api/file_get_html/) function in order to provide context by design.
|
||||
|
||||
```PHP
|
||||
$html = getSimpleHTMLDOM('your URI');
|
||||
```
|
||||
# getSimpleHTMLDOMCached
|
||||
The `getSimpleHTMLDOMCached` function does the same as the [`getSimpleHTMLDOM`](#getsimplehtmldom) function, except that the content received for the given URI is stored in a cache and loaded from cache on the next request if the specified cache duration was not reached. Use this function for data that is very unlikely to change between consecutive requests to **RSS-Bridge**. This function allows to specify the cache duration with the second parameter (default is 24 hours / 86400 seconds).
|
||||
The `getSimpleHTMLDOMCached` function does the same as the
|
||||
[`getSimpleHTMLDOM`](#getsimplehtmldom) function,
|
||||
except that the content received for the given URI is stored in a cache
|
||||
and loaded from cache on the next request if the specified cache duration
|
||||
was not reached.
|
||||
|
||||
Use this function for data that is very unlikely to change between consecutive requests to **RSS-Bridge**.
|
||||
This function allows to specify the cache duration with the second parameter.
|
||||
|
||||
```PHP
|
||||
$html = getSimpleHTMLDOMCached('your URI', 86400); // Duration 24h
|
||||
```
|
||||
|
||||
**Notice:** Due to the current implementation a value greater than 86400 seconds (24 hours) will not work as the cache is purged every 24 hours automatically.
|
||||
|
||||
# returnError
|
||||
**Notice:** Whenever possible make use of [`returnClientError`](#returnclienterror) or [`returnServerError`](#returnservererror)
|
||||
|
||||
The `returnError` function aborts execution of the current bridge and returns the given error message with the provided error number:
|
||||
|
||||
```PHP
|
||||
returnError('Your error message', 404);
|
||||
```
|
||||
|
||||
Check the [list of error codes](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for applicable error numbers.
|
||||
|
||||
# returnClientError
|
||||
The `returnClientError` function aborts execution of the current bridge and returns the given error message with error code **400**:
|
||||
The `returnClientError` function aborts execution of the current bridge
|
||||
and returns the given error message with error code **400**:
|
||||
|
||||
```PHP
|
||||
returnClientError('Your error message')
|
||||
@ -94,10 +93,12 @@ The `returnServerError` function aborts execution of the current bridge and retu
|
||||
returnServerError('Your error message')
|
||||
```
|
||||
|
||||
Use this function when a problem occurs that has nothing to do with the parameters provided by the user. (like: Host service gone missing, empty data received, etc...)
|
||||
Use this function when a problem occurs that has nothing to do with the parameters provided by the user.
|
||||
(like: Host service gone missing, empty data received, etc...)
|
||||
|
||||
# defaultLinkTo
|
||||
Automatically replaces any relative URL in a given string or DOM object (i.e. the one returned by [getSimpleHTMLDOM](#getsimplehtmldom)) with an absolute URL.
|
||||
Automatically replaces any relative URL in a given string or DOM object
|
||||
(i.e. the one returned by [getSimpleHTMLDOM](#getsimplehtmldom)) with an absolute URL.
|
||||
|
||||
```php
|
||||
defaultLinkTo ( mixed $content, string $server ) : object
|
||||
|
Reference in New Issue
Block a user