Skip to content

Instantly share code, notes, and snippets.

@moradi-morteza
Last active April 11, 2020 07:07
Show Gist options
  • Save moradi-morteza/2a8746a7eece42ba1cabb92914e172ea to your computer and use it in GitHub Desktop.
Save moradi-morteza/2a8746a7eece42ba1cabb92914e172ea to your computer and use it in GitHub Desktop.
[cache] #LaravelT
folder config/cache.php // you can write cache on file,database
// --------------Cache of File ---------------------
Cache.put("key","value",1); // remain in minutes
Cache.add("key","value",1); // if exist key befor it not add new value
Cache.get("key","default");
Cache.get("key",function(){}); // you can write function if key not exist
Cache.has("key") // check if cache with key exist or not
Cache.increament("key",1); // add 1 to key , for counter page ; you can do not write 1
Cache.decreament("key",1); // mins 1 **** and return new value ******
Cache.remember("key",1,function(){}); // do not go to fuction after first run function
Cache.forever("key","value");
Cache.forget("key"); // clean key and return true
Cache.pull("key"); // clean and return value
Cache.flush(); // clear all cache
Caceh.lock("key",1); // this need database cache
// you can use helper cache()
cache("key"); // get value with key
cache("key","defaule");
cache(['foo'=>50],10); // write to cache
cache("key")->forget(); // forget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment