Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it bad to consider PHP sessions and cookies as a caching option?
    primarykey
    data
    text
    <p>Below is a simple start for a driver based cache class in PHP. Another user submitted it... </p> <pre><code>&lt;?php class Cache { protected $Driver; public function __construct($driver) { require_once 'drivers/' . $drivers . '.driver.php'; $driver = "Cache_Driver_" . $driver; $this-&gt;Driver = new $driver; } public function create($key,$value) { return $this-&gt;Driver-&gt;create($key,$value); } public function read($key,$value) { return $this-&gt;Driver-&gt;read($key,$value); } public function update($key,$value) { return $this-&gt;Driver-&gt;update($key,$value); } public function remove($key) { return $this-&gt;Driver-&gt;remove($key); } } ?&gt; </code></pre> <p>My plan is to have separate class "files/drivers" for each method of caching I will have in my app. So far I plan on using, </p> <p><strong>- File<br> - APC<br> - Memcache or Memcached<br> - Redis<br> - Sessions<br> - Cookies</strong> </p> <p>So my main <strong>question(#1)</strong> here, I realize that sessions and cookies are not usually considered part of the caching but I think that they would fit in here, not to really "cache" a lot of data but more as a way to get/set my sessions and cookies, instead of having specific sessions and cookie classes, they would utilize my get/set/unset methods from this class. </p> <p>Please tell me what you think about this idea? Good, bad, any suggetions? Thank you! </p> <p><strong>question(#2)</strong> nFor my class that will be for sessions, I was thinking, in my constructor for the session Driver class, I could call </p> <p><code>session_start()</code></p> <p>there. Possible problem, wouldn't this require that I initiate the cache with session driver right away, like at the top of my application before anything else is called? Or even worse, would have to call session_start() outside of the class itself, at the top of my application? Again looking for suggetions, I feel I am overlooking something, thanks again for any help.</p> <pre><code>&lt;?php $cache = new Cache('Session'); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload