Help & KnowledgeBase

Using cache system 

Using cache system in your plugin involve you usiing our cache library.  crea8social makes use of simple and bootstrap functions to manipulate/cache data.This function are readily available on any page.

To save a data to cache the function  set_cache() can be called.

set_cache(@string $key, @mixed $value,@int $seconds);
               use 1:  set_cache('users',['userA','userB'],300);
                       users would be cached for 300 seconds.
               use 2:  set_cache('users',['userA','userB']);
                       users would be cached for a default time of 60 seconds.


This function set_cache() automatically generates a file and serializes the data into it.When not passed the third arguement which is the amount in seconds to cache data for will assume a default of 60 seconds to cache data.



This function get_cache() accepts a key and a default value to return as parameters to retrieve data assigned to that key from cache, and if no
        such key is found it returns $default value passed to it or if time data was cached for as elapsed it also returns $default.


This function set_cacheForever() functions similarly to set_cache(), but instead takes two parameters the key and value without the time.It saves data forever. It can be deleted when cache_flush() is called

set_cacheForever(@string $key,@mixed $value);
use : set_cacheForever('users',['userA','userB']);



forget_cache(@string $key);


Thanks for reading