How to realize nginx proxy_store File Management
How to achieve nginx proxy_store file management, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
one. Source code download address:
Https://github.com/cxwshawn/ngx_proxy_store_file_mgr
two. Introduction:
1) nginx-conf directory: the main implementation is based on the code of operating redis database in nginx.conf and based on lua; general process:
Obtain whether the cache lock is locked-> if it is locked, the file management process is doing lru policy, directly proxy to the upstream, and does not operate local files.
-> non-locked, then set the sorted set file access time in redis (i.e. score)
The redis structure is sorted by hash+sorted set; hash as md5 (uri)-> filepath and sortedset as: md5 (uri) + ngx.now () (score).
2). Src directory: the file management of nginx proxy_store, which is mainly realized by golang, the main idea:
At present, only when the remaining disk is less than 20%, the percentage of the sorted set sorting result in redis will be deleted in turn.
3), configuration items:
{
"MaxFileLimit": 100000, the maximum number of files. If this number is exceeded, do LRU (not implemented)
"CheckInterval": 20, check the interval between doing LRU
"ExpireDays": 7. Files whose expiration time exceeds 7day will be deleted.
"ErrorLog": true, whether to output error log
"AccessLog": false, whether to enter debug log
"SortedSetName": "defset". The name of sortedset in redis is the same as the name of sorte set in access_file.lua file.
"HashName": "defhash". The hash name in redis is the same as the hash name in access_file.lua file.
"RedisAddr": "127.0.0.1 6379", address of the redis database
"RoutineCount": the concurrency of 32 go lru
}
4), if you have any questions, mail to cxwshawn@yeah.net
After reading the above, have you mastered the method of how to manage nginx proxy_store files? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!