wandenberg / nginx-selective-cache-purge-module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

what's the relationship between Redis data and nginx cache keys zone?

xhy854 opened this issue · comments

As we know , nginx maintains cached content by cache keys zone as index. I think your module will copy cache keys in each zone to redis database, is that correct?
Really got confused by this module . You create a new process named cache synchronizer which is in a loop of dealing events. Is it responsible for copying cache key zone item to redis in the meanwhile of handling a request? What kind of events of a request will be used to make cache keys zone and Redis data synchronized ?

Please, take a look at #15 for additional information.
Nginx does not store the "plain" cache_key in memory only in the file, at the disk.
The synchronizer is used only during the time the "nginx cache loader" process is reading the values from disk to memory, it copies the values from disk and memory to Redis to build an updated index.
After the nginx loader process finish, the synchronizer runs one more time and stop.
From this point, every time a new entry is added to nginx cache it is added to the index in Redis.

Thanks for your reply.
I read your code carefully again and realize that it synchronizes cache keys to Redis by a LOG PHASE handler function. Nginx indeed does not store plain keys , cache key will only be stored after MD5 summarized.