php cache zend framework

2 Cevap php

sunucu tarafında PHP + Zend çerçevedir.

problem:

i have huge of data appox 5000 records and no of columns are 5 in input.txt file. i like to read all data into memory only once and send some data to the every browser request. but if i update that input.txt file then updated data must be auto synchronized to that memory location.

so i need to solve that problem by using memory caching technique.but caching technique has expire time.but if input.txt is updated before cache expire then i need to auto synchronize to that memory location.

now i am using zend framework 1.10.is it possible in zend framework. can anybody give me some line of code of zendfrmawork

i (dağıtılan) memchached sunucusu kullanmak için bir seçenek var.

Sadece zend framwork.

2 Cevap

(1s önbellek genelde Tamam) bu gibi tembel yükleme kullanın.

function getData() {
    $cache = ...; //get your memory cache here
    $cacheId = 'MyCacheId'; //cache id for your data
    $loadTimeCacheId = 'dataLoadCacheId'; //cache id for data load timestamp
    $cacheLength = 3600; //seconds

    $data = $cache->load($cacheId);
    $loadTime = (int) $cache->load($loadTimeCacheId);

    if (!$data || filemtime('/path/to/your/file') > $loadTime) {
        $data = ...; //real loading here

        $cache->save($data, $cacheId, array(/*no tags*/), $cacheLength); //save data to cache
        $cache->save(time(), $loadTimeCacheId, array(/*no tags*/), $cacheLength); //save load timestamp
    }

    return $data;
}

En iyi seçenek, dosyanızın ve Zend_Cache_Backend_Memcached için Zend_Cache_Frontend_File işaret kullanmaktır. Memcache veya APC fazla belleğe bir şey saklamak için nasıl hemen hemen başka hiçbir seçeneği yoktur. Bu IMO dış uzantısı olmadan yapılamaz.