1

server side is PHP + zend framework.

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 have no option to use memchached server(distributed).

Only zend framwork.

1
  • do/can you use APC/eAccelerator PHP extension if not reading entire input.txt with file_get_contents on each request would work just fine Commented Nov 12, 2010 at 20:05

3 Answers 3

1

It is possible to cache something like that using zend framework. Check Zend documentation online - its not complete but can give you a head start: http://framework.zend.com/manual/en/zend.cache.introduction.html

Sign up to request clarification or add additional context in comments.

Comments

1

Use lazy loading like this (1h cache is usually OK).

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;
}

Comments

0

Best option is to use Zend_Cache_Frontend_File pointed to your file and Zend_Cache_Backend_Memcached. There is virtually no other option how to store anything in memory than Memcache or APC. It cannot be done without external extension IMO.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.