PHPµÄAPCÄ£¿éʵÏÖÉÏ´«½ø¶ÈÌõ

5年以前  |  阅读数:213 次  |  编程语言:PHP 

APCÄ£¿e£¬ËuµÄÈ«³ÆÊÇAlternative PHP Cache¡£APC¿ÉÒÔ½«ËuÓÐPHP´uÂe»a±»»º´aeÆðÀ´£¬ ÁiÍaËu¿ÉÌa¹(C)Ò»¶¨µÄÄÚ´ae»º´ae¹¦ÄÜ.µ«ÊÇÕa¸o¹¦Äܲ¢²»ÊÇÊ®ÖÍeÃÀ,Óб¨¸ae˵Èç¹uƵ±Ê¹ÓÃAPC»º´aeµÄдÈe¹¦ÄÜ,»aµ¼Ö²»¿ÉÔ¤ÁϵĴiÎo.Èç¹uÏeʹÓÃÕa¸o¹¦ÄÜ£¬¿ÉÒÔ¿´¿´apc_fetch,apc_storeµÈ¼¸¸oÓeapc»º´aeÏa¹ØµÄº¯Êý¡£
ÖµµÃ¸ßÐ˵ÄÊÇ´Ó5.2¿ªÊ¼APC¼ÓÈeÁËAPC_UPLOAD_PROGRESS£¬½a¾oÁËÀ§ÈÅ´o¼ÒÒѾõĽø¶ÈÌoÎÊÌa¡£²¢ÇÒËu°ÑÔ­À´µÄÉÏ´«Ê±°ÑÁÙʱÎļþÈ«²¿»º´aeµ½ÄÚ´ae¸Ä³ÉÁ˵±ÁÙʱÎļþ´iµ½Ée¶¨ÖµÊ±¾Í×Ô¶¯±£´aeµ½Ó²ÅÌ£¬ÓÐЧµØ¸ÄÉÆÁËÄÚ´aeÀuÓÃ×´¿o¡£
ËuµÄ×÷ÓÃÔ­ÀiÊÇÔÚÉÏ´«Ê±ºo¸³Óeÿ¸oÉÏ´«Ò»¸oΨһµÄID£¬µ±PHP ½Å±¾ÊÕµ½Ò»¸oÉÏ´«Îļþʱ£¬½aÊͳÌÐo½«×Ô¶¯¼i²e$_POSTÊý×eÖÐÃuΪAPC_UPLOAD_PROGRESS µÄÒþ²Ø×ֶΣ¬Ëu½«³ÉΪ»º´ae±aÁ¿£¬´ae´¢¹ØÓÚÉÏ´«µÄÐÅÏ¢£¬ÕaÑu½Å±¾¾Í¿ÉÒÔͨ¹ýÉÏ´«µÄIDÀ´*ÃÎÊÉÏ´«ÎļþµÄ״̬ÐÅÏ¢¡£


    <!¨CÒÔÏÂΪÉÏ´«±iµ¥¨C>
    <form enctype="multipart/form-data" id="upload_form" action="" method="POST">
    <input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="upid"/>
    ÊÓƵ±eÌa£º<input type="text" id="subject" name="subject"/>
    ÊÓƵ˵Ã÷£º<input type="text" id="content" name="content"/>
    ÊÓƵTAG(ÒÔ¶ººÅ*Ö¸i)<input type="text" id="tag" name="tags"/>
    <input type="file" id="upfile" name="upfile"/>
    <input type="submit" id="filesubmit" value="ÉÏ´«" onclick="startProgress(¡®upid'); return true;"/>
    <!¨C×¢Òa:startProgress(¡®upid')ÖеIJÎÊýÊÇÄa´ÓphpÖÐ*ÖÅaµÄΨһÉÏ´«²ÎÊý¨C>
    </form>
    <!¨CÒÔÏÂΪÉÏ´«½ø¶ÈÌo¨C>
    <div id="upstatus" style="width: 500px; height: 30px; border: 1px solid ##ffffde; color:#796140;">
    </div
    <div id="progressouter" style="width: 500px; height: 20px; border: 3px solid #de7e00; display:none;">
    <div id="progressinner" style="position: relative; height: 20px; color:#796140; background-color: #f6d095; width: 0%; "></div>
    </div>

×iÖ÷ÒªµÄ¾ÍÊÇÄǸoAPC_UPLOAD_PROGRESSµÄÒþ²ØÓo£¬ÓÐÁËËu½Å±¾²ÅÄÜÈ¥*ÃÎÊÄ¿Ç°ÉÏ´«ÎļþµÄ״̬£¬ÁiÍa¼ÓÒ»¸oÏÔʾÉÏ´«×´Ì¬µÄdiv¾ÍºÃÁË¡£
ÏÂÃaeÊÇ´¦ÀiAjaxµÄ½Å±¾£¬ÓÃÁËJquery¿o¼Ü£¬json´«µÝÏuÏ¢¡£


    function getProgress(upid){
    var url = "<{$siteurl}>epadmin/upprocess";
    $.getJSON(
    url,
    { progress_key: upid },
    function(json){
    $("#progressinner").width(json.per+"%");
    $("#upstatus").html(¡®Îļþ´oС:'+json.total+¡®KB'+¡® ÒÑÉÏ´«:'+json.current+¡®KB');
    if (json.per < 100){
    setTimeout(function(){
    getProgress(upid);
    }, 10);
    }else{
    $("#upstatus").html("ÊÓƵÉÏ´«Íe³É£¬ÕýÔÚ´¦ÀiÊý¾Ý£¬ÇeÉÔºo¡­¡­");
    }
    }
    )
    }
    function startProgress(upid){
    $("#progressouter").css({ display:"block" });
    setTimeout(function(){
    getProgress(upid);
    }, 100);
    }

ÔÙÏÂÀ´¾ÍÊǶÁÈ¡ÉÏ´«×´Ì¬µÄPHP´uÂeÁË£¬ÖÁÓÚÉÏ´«ÎļþµÄ´¦Ài¿ÉÒÔ°´ÕÕƽ³£×Ô¼ºµÄÀ´Ð´¡£
//ÉÏ´«Îļþ²Ù×÷º¯Êý£¬¿É°´ÕÕ×Ô¼ºµÄÐeÒª±aд


    function upflvAction()
     {
     if($_SERVER['REQUEST_METHOD']==¡®POST'){
     $subject = trim($this->f->filter($this->_request->getPost(¡®subject')));
     $content = trim($this->f->filter($this->_request->getPost(¡®content')));
     Zend_Loader::loadClass(¡®Custom_FlvOp');
     $flv = new Custom_FlvOp;
     $flv->uploadFlv(¡®upfile',$subject,$content);
     }
     }
     //Õa¾ÍÊǶÁÈ¡ÉÏ´«×´Ì¬µÄº¯ÊýÁË~~
     function upprocessAction()
     {
     if(isset($_GET['progress_key'])) {
     $status = apc_fetch(¡®upload_'.$_GET['progress_key']);
     $json = array(
     ¡®per'=>$status['current']/$status['total']*100,
     ¡®total'=>round($status['total']/1024),
     ¡®current'=>round($status['current']/1024),
     );
     require_once("Zend/Json.php");
     echo Zend_Json::encode($json);
     }
     }

ºÃÁË£¬ÏÖÔھͿÉÒÔ½«Æa²¿Êð×Ô¼ºµÄÕ¾µaÖÐÁË£¬×Ô¼º¿´¿´Ð§¹uÊDz»ÊǺܿa£¿

ÒÔÉϾÍÊÇPHPµÄAPCÄ£¿eÖÆ×÷ÉÏ´«½ø¶ÈÌoµÄ¹Ø¼uµa½eÉÜ£¬Ï£Íu¶Ô´o¼ÒµÄѧϰÓÐËuÆo*¢£¬¶Ô´o¼ÒÓÐËu°iÖu¡£

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例