Thoughts on Cache Usage 1

Source: Internet
Author: User
Tags couchbase

Common cache Products

  • Replace your Memcached Tier with a Couchbase Cluster
There are windows and linux versions. Couchbase cluster installation requires CPU usage, because several installation prompts I do not support CPU usage and other information.
  • Windows AppFabric
AppFabric is a series of integrated technologies provided by Microsoft for windows server. It facilitates the construction, expansion, and management of applications running on IIS. Caching is one of the features provided by AppFabric and supports distributed caching.
  • Memcached
Http://memcached.org/

The old distributed cache.

  • Redis
Http://redis.io/popular key-value NoSQL database, can be used as a cache. You can store string, hash, list, set, sorted set, and other types of values.
  • Mongodb
Http://www.mongodb.org
Popular document-type NoSQL databases are easy to expand and have a free structure. They can also be used as caches. Memcached, redis, and mongodb may not run well on windows for some reasons, and some strange problems may occur. This is because they do not have sufficient support for windows, or they are not recommended for use on windows. Frequently cached content:
  • CATEGORY Information
  • Infrequently changed information
In fact, product information and even user information, such as the userid corresponding to username and username corresponding to userid, in fact, the meaning of the cache is quite large. If you only want the userid corresponding to the username, Do you not need to query the database? It seems a waste of time. By extension, many requirements for querying a small amount of common information based on the primary key can be implemented using the cache, replacing the query database. At this point, some people will say, "What should I do if the information expires? What should I do if the user modifies the information .". Generally, the cache provides an expiration mechanism. The relative time expires and the absolute time expires. After modifying the information, you can set the absolute expiration time to the past time. When you access the cached information next time, it will be obtained from the data source because the cache is invalid. You can also update the cache after modifying the information to keep the cache updated. First, cache should be a component and a basic component independent of other components. Provides key-value access. The key-bit string type and the value is of the object type. Of course, it would be better if the value can provide multiple data types. For example, redis provides string, hash, list, set, sorted set. The cache expiration function is provided. The absolute time expires and the relative time expires. Provides the cache dependency function, dependent files, and dependent databases. You can even provide dependency interfaces to implement the dependencies you need. Better yet, it also supports distributed caching. Since it is a basic component, it will certainly be called by other components to cache data for other components. Our applications are often layered, such as the business layer and persistence layer. Assume that the business layer needs to provide the cache function for business objects. The business layer needs to introduce the cache component and call the interface of the cache component to cache, retrieve, and expire the business objects. The service layer introduces the cache component to cache business objects. It should be a black box for the outside, and there is no need for the outside to care about using the cache component. The specific details are used and which scenarios are used, the interface for external access to business objects should not change, and no cache-related parameters are required. However, external callers should be allowed to disable caching. That is to say, external callers should be able to declare that they do not use the caching mechanism of business objects when initializing business objects, you can also disable or enable the cache mechanism for business objects during use. Suppose that I am a caller at the business layer, and I want to set whether to enable the cache mechanism of the Business Object When initializing the business layer object. When using initialized business-layer objects, you can also enable or disable the cache mechanism as needed. Not complete, To be continued...

This article is from the "breakthrough IT architects" blog, please be sure to keep this source http://virusswb.blog.51cto.com/115214/1096939

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.