Hi all,
A quick question, I think I’m completely misunderstanding the process of file dependency when caching, or doing something horribly wrong. How I understand it is that when caching an item with a file dependency like so:
[PHP]Yii::app()->cache->set(‘foo’, ‘bar’, 30, new CFileCacheDependency(’/myfile.txt’));[/PHP]
‘foo’ will remain in cache with the value ‘bar’ until;
a: the cache "time" expires (30 second in this case), or
b: the file is modified (i.e. saved)
However, running the above code and then on a separate page:
[PHP]$foo = Yii::app()->cache->get(‘foo’);
echo $foo;[/PHP]
This output’s ‘bar’ as you’d expect, however when I edit (or even delete) myFile.txt it still outputs ‘bar’, even though I’m not running the set() method again.
I’ve tried using an absolute and a relative path to the file, but with the same results, am I setting the dependency up wrong?
What I’m eventually trying to do is set a db query to use a file dependency to cache like so:
[PHP]$fileDependency = new CFileCacheDependency(’/myFile.txt’)
Category::model()->cache(60, $fileDependency)->findAll($criteria)[/PHP]
Any pointers to the right direction would be greatly appreciated,
Thanks!