Writing in the front

I could have had a good rest after work, but I had just laid down when the bell rang.

‘Hello, there! .

“Hello, Glacier, is he asleep? My name is XXX, I have a problem, I want to migrate the cache server from CentOS to Windows, and I want to use Memcached.

“What? Why Windows? Why Memcached? Doesn’t Redis smell good? Redis is much more powerful than Memcached!!”

“I know, but I’m not familiar with Linux or Redis. I wanted to migrate to Memcached to test it out.” .

“Not very familiar slowly accumulate, slowly learn”.

“But the project will be online next week. I’m not sure. What should I do? You help me with the next bai, the project first online, I will slowly learn later.

I like to help people, so I got up in the cold to help him migrate the cache server.

The article has been included:

Github.com/sunshinelyz…

Gitee.com/binghe001/t…

What is the Memcached

In short, Memcached is an open source, high-performance, distributed caching system with memory-based key-value storage for storing small chunks of arbitrary data (strings, objects).

Let’s take a look at how to install Memcached on a Windows server.

Install Memcached

Download memcached on the server

32bit: memcached-win32-2.4.4-14.zip contains 6 files. Put the decompressed folder in any location (e.g. D:\memcached).

Memcached – win32-1.4.4-14. Zip download page: blog.couchbase.com/memcached-1…

64bit: if you need win64, download memcached-win64-2.4.4-14.zip, there are three files in it, use these three files to overwrite the same file in Win32.

Memcached – win64-1.4.4-14. Zip download page: blog.couchbase.com/memcached-w…

Run cmd.exe as an administrator

Run cmd.exe as an administrator and go to the memcached folder

Such as:

cd D:\memcached
Copy the code

Note: Failed to install service or service already installed is displayed if you do not run as an administrator.

Install memcached

d:\memcached memcached.exe -d install
Copy the code

You can see memcached in Control Panel -> Administrative Tools -> Services.

Start memcached

Startup Method 1:

d:\memcached> memcached.exe -d start
Copy the code

No message is displayed. However, select Show all user processes in Task Manager. You can see that the memcached.exe process is running on the default port 11211.

Startup Method 2:

[Control Panel]->[Administrative Tools]->[Services] Find the memcached service and double-click on it to open it

  • Startup type: Select [Automatic]
  • Service status: Click “Start” below
  • Note: There are some differences between the path of the executable file and the path I mentioned above that can be ignored

Set basic memcached parameters

  • -p Indicates the listening port
  • -l Indicates the IP address of the connection. The default IP address is the local computer
  • -d start Starts the memcached service
  • -d restart Restarts the memcached service
  • Stop – d | closed running memcached service shutdown
  • -d install Installs the memcached service
  • -d uninstall Uninstalls the memcached service
  • -u runs as root (only valid if run as root)
  • -m Indicates the maximum memory usage (unit: MB). The default 64 MB
  • -m Returns an error instead of deleting an item when memory runs out
  • -c Maximum number of simultaneous connections. The default value is 1024
  • -f Block size growth factor. The default value is 1.25
  • -n Minimum allocated space. The default value is 48
  • -h Displays help information

To set the parameters, stop memcached and then set them on the command line. For example:

 D:\memcached> memcached.exe -m 1 -d start
Copy the code

Stop the memcached

D:\memcached> memcached.exe -d stop
Copy the code

Uninstall the memcached

D:\memcached> memcached.exe -d uninstall
Copy the code

Modify the parameters

In Windows, you need to modify the registry information, open the registry, and find

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached 
Copy the code

There is an “ImagePath” entry with the value:

"D:\memcached\memcached.exe" -d runservice 
Copy the code

Add -m 1024-c 2048-p 11210 to the end. Such as can be. It takes effect after the service is restarted

After Memcached is installed, migrate the cached data from Redis to Memcached, and change the Redis connection information in the project to Memcached.

Additional installation package

You can link download.csdn.net/detail/l102… Download the Memcached installation package.

conclusion

Linux+Redis is better than Windows+Memcached in terms of performance, persistence and concurrency. Why use Windows+Memcached? The reason is not familiar with Linux+Redis! What does that tell us?

Friends still want to update their technology stack in time! Otherwise, there are many powerful and awesome technologies that you won’t be able to use due to the limitations of your technology stack. Don’t kill yourself. Don’t ask “How can programmers Kill Themselves Faster?” As said in

Well, that’s enough for today, I’m The glacier, you can leave a message below, you can also add my wechat, exchange technology together, together to advance, together niubi ~~