Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache problem , should condider the criteria #3

Open
yiqing-95 opened this issue May 5, 2012 · 2 comments
Open

cache problem , should condider the criteria #3

yiqing-95 opened this issue May 5, 2012 · 2 comments

Comments

@yiqing-95
Copy link

getAllTags or getAllTagsWithModelsCount method when using cache should consider the criteria:

you see the code is like this

public function getAllTags($criteria = null) {
        if(!($tags = $this->cache->get('Taggable'.$this->getOwner()->tableName().'All'))){

            ...

            $this->cache->set('Taggable'.$this->getOwner()->tableName().'All', $tags);
        }

        return $tags;
    }

when the criteria is different method will return the same thing . may be it should like this (not sure)

public function getAllTags($criteria = null) {
                $extraCacheKey = empty($criteria) ? '' : serialize($criteria);  //  var_export($criteria,true); may consider too !

                if(!($tags = $this->cache->get('Taggable'.$this->getOwner()->tableName().'All'.$extraCacheKey ))){

            ...

            $this->cache->set('Taggable'.$this->getOwner()->tableName().'All'.$extraCacheKey, $tags);
        }

        return $tags;
    }

same problem with getAllTagsWithModelsCount method

@cebe
Copy link
Member

cebe commented May 5, 2012

You are right, cache must consider criteria.

@yiqing-95
Copy link
Author

so do you have any solution to that ?
i just think about using CExpressionDependency , but not very sure whether there is a better solution ?

and not too clear about the cache expiration for using CExpressionDependency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants