Memcached application skills

Source: Internet
Author: User
Memcached usage tips: how do you use this cache system? if each function is used, do you first determine whether there is a cache in memcache? If yes, do you write it to memcached first? The code is: if (! Memcache) {& nbsp; memcached usage tips
How do you use this cache system? if every function is used, you must first determine whether there is any cache in memcache. if there is any cache, will it be written to memcached first?
The code is:
If (! Memcache ){
Write data to memcached
} Else {
Get data directly from memcached
}

The problem is, if every function and module is used to judge memcached, will it be very troublesome? is there any good architecture method? Share:
------ Solution --------------------
So Far

This is actually just a few things.

If you need to use this in many places, you can encapsulate the storage, query, and cache of the database. each time you directly call the encapsulated method, you do not need to write the get and set of memcache every time.
------ Solution --------------------
The principle of using cache (no matter what kind of cache) is:
Write the cache only when data is generated different from the cached data. Such as database insertion and modification
Read-only in other places

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.