Laravel cache Problems

Source: Internet
Author: User
Laravel cache. The default format is File Cache. Therefore, when writing business code, you need to perform ifelse in the Controller to determine whether to first access the cache, the cache does not access the database again, or Laravel already has a default method, and you will first access the cache, the cache does not automatically remove shards... laravel cache. The default format is File Cache.
Therefore, when writing business code, you need to make if else in the Controller to determine that the cache is accessed first, and the cache does not access the database again,
Or does Laravel already have a default access method. Will it access the cache first, and the cache will not automatically access the database?

If laravel already defines,
So what is the cache policy defined by it: When to generate the cache and how long the cache will be stored?

Reply content:

Laravel cache. The default format is File Cache.
Therefore, when writing business code, you need to make if else in the Controller to determine that the cache is accessed first, and the cache does not access the database again,
Or does Laravel already have a default access method. Will it access the cache first, and the cache will not automatically access the database?

If laravel already defines,
So what is the cache policy defined by it: When to generate the cache and how long the cache will be stored?

UseCache: rememberMethod. If the cache does not exist, access the database and cache it.

$ Value = Cache: remember ('users', $ minutes, function () {return DB: table ('users')-> get ();});

For more information, see the manual.
When the cache is generated depends on whether the cache is defined and how long the cache is saved depends on the time you set ..

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.