Home >Backend Development >C#.Net Tutorial >Application of Memcached in .net
1) Extract the file to c:\memcached (you can also choose any location)
2) The command line enters 'c:\memcached\memcached.exe -d install'
##3) The command line enters 'c:\memcached\memcached.exe -d start', this command starts Memcached, the default listening port is 11211
4) You can view its help through memcached.exe -h
##2 , Client installation and reference
# For client operation server, we have a variety of Optional method, here, we choose to use dll. Because the dll method is faster to generate and avoids cumbersome settings in the configuration file, which is more convenient. For telnet commands, etc., we can use them on the server side to check data, check the cache hit rate, etc.
1. References about Dll
After downloading the Dll, add the reference as shown in the project
2, there may be problems
Three, in-depth understanding of Memcached mechanism
2) Memcached’s server-client communication does not use XML and other formats, but uses a simple text line-based protocol. Therefore, data can also be saved and obtained on memcached through telnet. .
2, event processing based on libevent
2) Memcached uses libevent to handle concurrent network connections, which can maintain the ability to respond quickly even in large concurrency situations.
3, built-in memory storage method
4, client-based distributed
# Code experience:
4. Memcached and session
## 2) The focus of the problems to be solved is different cache is used. The state management stuff in Net also feels quite powerful: 1. Cache dependencies: You can rely on files, databases, or combinations of dependencies, and it provides a notification mechanism for data expiration to facilitate us to update the data in time when it expires. 2. Use of notification mechanism: In the past, the polling mechanism was used to determine whether the data had expired. It was similar to looping to see if the data had been updated. If it had been updated, the cache was updated at this time. But I always feel that the polling mechanism is very strange. For example, when I boil a pot of water at home, I should not always check to see if the water is boiling, but I should check if the water is boiling and then a sound will tell me that the water is boiling. This is what the notification mechanism means. As for the principle of the notification mechanism, you can check the observer pattern. Among the 23 design patterns, this is used quite a lot. When I first used memcached, due to cache reasons, I naturally thought of this notification mechanism. After checking, it seems that memcached does not have this. If you want to make an expired update yourself, Only polling mechanism can be used. But thinking about the usage scenarios of memcached, we will find that an expiration time is enough. 1) Frequently changing and unstable data does not need to be stored in real time (such as users Online status, number of online people) 2) News from the portal website, etc., I think the static page of the page still cannot meet the requirements, and can be put in Memcached (with jQuery's Ajax request) ...... ## Since memcached does not have a built-in authentication mechanism, it is possible to log in using telnet to access the ip+port, and then inside The data becomes lambs to be slaughtered. In order to avoid being hacked, we can close the external access port on the memcached server and only allow local programs to access. 1) Support more Value type ##3) Supports master-slave synchronization: data can be synchronized from the master server to any number of slave servers, and the slave server can be associated with other slave servers Main server. This allows Redis to perform single-level tree replication. Saving can write data intentionally or unintentionally. Since the publish/subscribe mechanism is fully implemented, when the slave database synchronizes the tree anywhere, it can subscribe to a channel and receive the complete message release record of the master server. Synchronization is helpful for scalability and data redundancy of read operations. 2, EHCACHE 2) Open source Java distributed cache: Mainly for general cache, Java EE and lightweight containers. It features memory and disk storage, cache loaders, cache extensions, cache exception handlers, a gzip cache servlet filter, support for REST and SOAP APIs, and more. . . . . . . . . . The above is the content of Memcached application in .net. For more related content, please pay attention to the PHP Chinese website (www.php.cn)! 5. Memcached and Cache
6. Applicable scenarios of memcached
Seven, memcached security issues
Eight, comparison of similar technologies
1,Redis
# 1) The internal cache framework of the pure Java process has the characteristics of fast and hard -working. It is the default cacheProvider in Hibernate .