Welcome Guest, Not a member yet? Register   Sign In
Which Cache use and how?
#2

(This post was last modified: 05-19-2015, 11:55 AM by kilishan.)

According to the manual for both version 2 and 3, you would use
Code:
$this->cache->delete('cache_item_id');
to delete an item.

So, the only trick is to ensure that you've assigned a name that will be unique when you create the cache, and then use that same name to delete it later. Typically this would contain the item's ID, or page name, etc, and the object type. Any combination that won't conflict with something else within your application. If that page can vary based on the user's role, or whether they are logged in, you can include the role name/id as part of it, also.

Just re-read your post and it looks like you're naming your cache item 'controller/method'. In that case, there's nothing unique about each item, so a better name might be 'controller/method/post-{id}', or simply 'post-{id}'. If the contents of your post varies based on the role of the person viewing it, you could include that as part of the cache name also so you don't accidentally show the wrong thing to people who don't need it.

As for which cache driver to use? Depends on your needs. The file-based one is a great one to start with since it doesn't require anything specific on your servers. And it's simple to change out later.
Reply


Messages In This Thread
Which Cache use and how? - by swissmistery - 05-19-2015, 11:14 AM
RE: Which Cache use and how? - by kilishan - 05-19-2015, 11:49 AM
RE: Which Cache use and how? - by swissmistery - 05-19-2015, 12:25 PM
RE: Which Cache use and how? - by kilishan - 05-20-2015, 06:39 AM
RE: Which Cache use and how? - by swissmistery - 05-20-2015, 03:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB