Welcome Guest, Not a member yet? Register   Sign In
Phil Sturgeon's Cache Library
#1

[eluser]Peanut[/eluser]
Code:
// cached model call
$this->cache->model('blog_m', 'getPosts', array($category_id, 'live'), 120); // keep for 2 minutes

Ok.. so one negative is that he has horrible documentation. Anyway, what exactly is the array (3rd parameter) suppose to be?
I know 1st parameter is model name.
2nd parameter is method name.
3rd parameter, I have no idea.
4th paramter, seconds until cache is deleted.

So can anyone help me on what the 3rd parameter is?

EDIT
And another question.
Is there a way to make a cache live until a certain update on the database table?
#2

[eluser]Aken[/eluser]
Looking at the source code answers your question pretty quickly. Not familiar enough to answer the second part, though.
#3

[eluser]Peanut[/eluser]
I did look at the source code.. I don't know if I'm just overlooking it, but I dont' know what to put in the array... or what I'm suppose to put at all.
I know everything else.
And I figured out to have it live for unlimited amounts of time and manually delete and recache it, you can either put 0 in the 4th parameter or leave it blank.
#4

[eluser]CroNiX[/eluser]
Never looked at it or used it so it's a total guess...but probably parameters passed to the method.
#5

[eluser]Eduard Stankovic[/eluser]
3rd param is array of parameters ...
Code:
$this->cache->model('blog_m', 'getPosts', array($category_id, 'live', $foo, ....... ), 120);
is same ( but cached) as :
Code:
$this->blog_m->getPosts($category_id, 'live', $foo, .......) ;

Do u understand now ?
#6

[eluser]Peanut[/eluser]
Yes it all makes perfect sense now =) I didn't know you actually replaced the model call with this.
Anyway, I have a news system and I want to cache the posts, but it also counts the comments each news post has, but everytime a person posts, I want to show the latest posts.
However... is there anyway you can make a certain part not cache and the others cache. I would like to cache the actual news post until a new post is inserted by admin, but would like to show the latest comments so I should probably not cache those (COUNT(comment_id)).

And why is it giving me this error:
Code:
A PHP Error was encountered
Severity: Warning
Message: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object
Filename: libraries/Cache.php
Line Number: 130
#7

[eluser]Eduard Stankovic[/eluser]
when you add new post call this:

Code:
$this->cache->delete_all();

it deletes all cached files
#8

[eluser]Peanut[/eluser]
Yeah, but then there is really no point in caching the news post if you have to delete it every single time a user comments, is there?.. That seems wasteful..
#9

[eluser]Eduard Stankovic[/eluser]
Code:
$data = $this->cache->get('cached-name');

// Delete cache
$this->cache->delete('cached-name');

try to play around it .... maybe one of them will be what are u looking for ...





Theme © iAndrew 2016 - Forum software by © MyBB