Пример #1
0
 static function toMinutes($str)
 {
     if (is_string($str)) {
         return floor(duration::toSeconds($str) / 60);
     } else {
         return $str;
     }
 }
Пример #2
0
 function onDownloadProgress($current, $max)
 {
     if ($max) {
         if (duration::since($lastupdate) > 5) {
             // only update every 5 secs
             $this->setState(LdwpJob::STATE_RUNNING, $current, $max);
         }
     }
 }
Пример #3
0
 /**
  * Puts (or updates) the item into the cache. Use duration::toMinutes()
  * to calculate a proper expiry for the item.
  *
  * @param string $name The name of the object
  * @param string $contenttype The content type of the object
  * @param string $data The object contents
  * @param int $expiry The expiry of the content in minutes
  * @return boolean True if it was successful
  */
 function set($name, $contenttype, $data, $expiry = null)
 {
     $hash = md5($name);
     $base = config::get('lepton.fscache.path', 'cache');
     if (!$expiry) {
         $expiry = config::get('lepton.fscache.defaultexpiry', '1h');
     }
     $expires = duration::toSeconds($expiry);
     $db = DBX::getInstance(DBX);
     $db->getSchemaManager()->checkSchema('fscache');
     $db->updateRow("REPLACE INTO fscache (hash,contenttype,expires) VALUES ('%s','%s','%d')", $hash, $contenttype, $expires);
     file_put_contents($base . '/' . $hash, $data);
 }
Пример #4
0
 /**
  * @brief Set or update an entry in the cache
  * 
  * @param String $key The key to set
  * @param Mixed $value The data to set
  * @param Mixed $validity Validity as a string, such as "5m" or "1h"
  */
 public static function set($key, $value, $validity = null)
 {
     self::initialize();
     if ($validity) {
         $sec = duration::toSeconds($validity);
         $expires = $sec;
     } else {
         $expires = 0;
     }
     self::$mci->set($key, $value, $expires);
     self::check();
 }