Пример #1
0
 /**
  * Create a download
  * @since Version 3.10.0
  * @param int $id
  * @return \Railpage\Downloads\Download
  */
 public function createDownload($id = null)
 {
     $Registry = Registry::GetInstance();
     $cachekey = sprintf("railpage:download=%d", intval($id));
     try {
         $Download = $Registry->get($cachekey);
     } catch (Exception $e) {
         $Download = new Download($id);
         $Registry->set($cachekey, $Download);
     }
     return $Download;
 }
Пример #2
0
 /**
  * Return a new instance of Image
  * @since Version 3.9.1
  * @param int|string $id
  * @param string $provider
  * @param int $options
  * @return \Railpage\Images\Image
  */
 public static function CreateImage($id = null, $provider = null, $options = null)
 {
     $Redis = AppCore::GetRedis();
     $Registry = Registry::GetInstance();
     $cachekey = sprintf("rp:v2;cache.image=%s;o=%s", $id, crc32(json_encode($options)));
     if ($id != null && $provider == null) {
         return new Image($id, $options);
         try {
             $Image = $Registry->get($cachekey);
         } catch (Exception $e) {
             if (!($Image = $Redis->fetch($cachekey))) {
                 $Image = new Image($id, $options);
                 $Redis->save($cachekey, $Image, strtotime("+10 minutes"));
             }
             $Registry->set($cachekey, $Image);
         }
         return $Image;
     }
     $cachekey .= sprintf(";p=%s", $provider);
     #$Registry = Registry::getInstance();
     #echo $cachekey;die;
     return (new Images())->findImage($provider, $id, $options);
     try {
         $Image = $Registry->get($cachekey);
     } catch (Exception $e) {
         if ($Image = $Redis->fetch($cachekey) && $Image instanceof Image) {
             $Registry->set($cachekey, $Image);
             return $Image;
         }
         try {
             $Images = new Images();
             $Image = $Images->findImage($provider, $id, $options);
             $Redis->save($cachekey, $Image, strtotime("+10 minutes"));
             $Registry->set($cachekey, $Image);
         } catch (Exception $e) {
             $Image = false;
         }
     }
     return $Image;
 }