Home  >  Article  >  Backend Development  >  Problem with Redis storing HTML after rendering the view

Problem with Redis storing HTML after rendering the view

WBOY
WBOYOriginal
2016-12-01 00:26:001152browse

In the framework, after rendering the view, cache all the view content into Redis.
When the visiting address or conditions are consistent during the next visit, the cached content in Redis will be read directly.

What type of storage is more appropriate to use in Redis.
I am currently using String and tried hashing, but there is a drawback, that is, the expiration time cannot be set for each k-v,
And I need to set a separate validity time for each cached content

I would like to ask if you have any better suggestions or a solution that can achieve better performance and content scheduling in Redis! ?

Thank you.

Reply content:

In the framework, after rendering the view, cache all the view content into Redis.
When the visiting address or conditions are consistent during the next visit, the cached content in Redis will be read directly.

What type of storage is more appropriate to use in Redis.
I am currently using String and tried hashing, but there is a drawback, that is, the expiration time cannot be set for each k-v,
And I need to set a separate validity time for each cached content

I would like to ask if you have any better suggestions or a solution that can achieve better performance and content scheduling in Redis! ?

Thank you.

Use string, no problem.

Considering performance, remember to enable connection reuse. If your bandwidth is not enough, you can use compression such as zlib or lzo. If you want a better compression rate, you can pre-calculate a more targeted dictionary (Python's own zlib library supports this operation, and for PHP, write your own extension...).

Would it be faster to directly generate the corresponding static files...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn