We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

about cache never expries.

https://groups.google.com/forum/?fromgroups=#!topic/phalcon/xn1_Ij8sD6Q

if have not never expries.

for example:

<?php
class TestController extends ... {
    public function newAction () {}
    public function editAction () {}
    public function saveAction () {
              //insert operate
              $data = Tests::find();
              $this->cache->save($key,$data);
    }
    public function updateAction () {
              // update operate
              $data = Tests::find();
              $this->cache->save($key,$data);
    }

    public function listAction() {
             $data = $this->cache->get($key); // if can set cache never expries.

             // or can not set cache never expries, at ervery get cache's ,need write follow code 
             // not for Performance 
             if($data === null ) {
                  $data = Tests::find();
                  $this->cache->save($key,$data);
             }
    }
    public function deleteAction () {}
}

I could be wrong but I do not think that there is a never expire option in many cache systems.

You are correct. The only way to set the cache to "never expire" is to set the lifetime to something really large.

If you set the $lifetime to 30 days for the items you want, then your performance impact will be very very small.

In my projects, for data that does not change often, I usually set the cache to 1 day. This means that I have only one query to generate the data per day. That is pretty good :)



17.8k

:) thanks

// or can not set cache never expries, at ervery get cache's ,need write follow code // not for Performance

i known performance is no problem, i only think at any need get cache data (as: listAction,... otherAction ), i need write the follow code, i only think no necessary

if($data === null ) {
                  $data = Tests::find();
                  $this->cache->save($key,$data);
             }

tomorrow night, i think, i set the $lifetime 100 year, :)