Roxen.git / server / modules / tags / insert_cached_href.pike

version» Context lines:

Roxen.git/server/modules/tags/insert_cached_href.pike:30:   private HrefDatabase href_database;   private constant unavailable = "The requested page is unavailable at the moment. "    "Please try again later";      void create() {    defvar("fetch-interval", "5 minutes", LOCALE(0, "Fetch interval"),    TYPE_STRING|VAR_MORE,    LOCALE(0, "States how often the data of an URL should be updated. "    "In seconds, minutes, hours or days."));    -  defvar("fresh-time", "20 minutes", LOCALE(0, "Fresh time"), +  defvar("fresh-time", "0", LOCALE(0, "Fresh time"),    TYPE_STRING|VAR_MORE,    LOCALE(0, "States how long data in the database can be considered fresh enough" -  " to display. In seconds, minutes, hours or days.")); +  " to display. In seconds, minutes, hours or days. As default this" +  " is 0, which means that this attribute is not used and that there" +  " are no restrictions on data freshness."));       defvar("ttl", "7 days", LOCALE(0, "Time to live"),    TYPE_STRING|VAR_MORE,    LOCALE(0, "States how long unrequested data can exist in the database"    " before being removed. In seconds, minutes, hours or days."));       defvar("timeout", "10 seconds", LOCALE(0, "Timeout"),    TYPE_STRING|VAR_MORE,    LOCALE(0, "The timeout when fetching data from a server. In seconds, minutes, "    "hours or days."));
Roxen.git/server/modules/tags/insert_cached_href.pike:280:       sql_query("INSERT IGNORE INTO " + request_table    + " values (%s, %d, %d, %d, %d, %d, %d, %d)", args["cached-href"],    args["fetch-interval"], args["fresh-time"], args["ttl"],    args["timeout"], args["time-of-day"], next_fetch, time());       sql_query("INSERT IGNORE INTO " + data_table + " values (%s, '', 0)",    args["cached-href"]);       result = sql_query("SELECT data FROM " + data_table + " WHERE url='" + -  args["cached-href"] + "' AND " + time() + " - latest_write < " -  + args["fresh-time"]); +  args["cached-href"] + "' AND (" + time() + " - latest_write < " +  + args["fresh-time"] + " OR " + args["fresh-time"] + " = 0)");       if (result && sizeof(result) && result[0]["data"] != "") {    DWRITE("in get_data(): Returning cached data");       return result[0]["data"];    } else if (!args["pure-db"]) {    DWRITE("in get_data(): No cached data existed so performing a synchronous fetch");       string data = fetch_url((["url":args["cached-href"], "timeout":args["timeout"],    "sync":1]), header);
Roxen.git/server/modules/tags/insert_cached_href.pike:457:    RXML.run_error("Hour must be between 0 and 23, minutes between 0 and 59");       db_args["time-of-day"] = hour * 3600 + minute * 60;       } else if (orig_args["fetch-interval"] && valid_arg(orig_args["fetch-interval"])) {    db_args["fetch-interval"] = orig_args["fetch-interval"];    } else {    db_args["fetch-interval"] = query("fetch-interval");    }    -  if (orig_args["fresh-time"] && valid_arg(orig_args["fresh-time"])) +  if (orig_args["fresh-time"] && +  (valid_arg(orig_args["fresh-time"]) || orig_args["fresh-time"] == "0"))    db_args["fresh-time"] = orig_args["fresh-time"];    else    db_args["fresh-time"] = query("fresh-time");       if (orig_args["ttl"] && valid_arg(orig_args["ttl"]))    db_args["ttl"] = orig_args["ttl"];    else    db_args["ttl"] = query("ttl");       if (orig_args["timeout"] && valid_arg(orig_args["timeout"]))