Introduction to Laravel 5.3 cache () function usage

Source: Internet
Author: User

Since come to Beibei, work more and more busy, has not done a day a more, one weeks to do three update is very difficult, ashamed ...

Today we'll take a look at one of the new auxiliary functions in Laravel 5.3: Cache.

This auxiliary function is similar to the other two auxiliary functions: Session and Cookie, they all have three usages: get the value, set the value and return the instance of the corresponding service, take the session as an example:

Session (' ABC ', NULL) gets the value of the ABC and returns NULL if NULL
session ([' ABC ' => ' Laravel College ']) set the value of ABC to Laravel College

Session () Returns an instance of SessionManager
The third usage means that you can use the session ()->all () to replace Session::all ().

In fact, cache this auxiliary function long overdue, Jeffrey Way (laracasts webmaster) has implemented such a function, in order to respond to the voice of the masses, laravel 5.3 to the function into the core library.

As with the session, the cache function also has three different uses:

Cache (' abc ', NULL) gets the cached value of ABC and returns NULL if not
Cache ([' ABC ' => ' Laravel College '], 5) used to set the cached value, valid for 5 minutes
Cache () Returns an instance of CacheManager

The same third usage means you can use a method like cache ()->forever () to replace Cache::forever (), and of course you can invoke many other functions that you can test on your own.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.