Use Redis for CacheMarkDownField on non AR models
What does this MR do?
Based from https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23513 which is done by @reprazent. This MR merged the commit from that MR and fixes the conflicts and ensure it works with the recent state of GitLab Markdown.
This allows using
CacheMarkdownField for models that are not backed by ActiveRecord.
When the including class inherits
ActiveRecord::Base we include
Gitlab::MarkdownCache::ActiveRecord::Extension. This will cause the markdown fields to be rendered and the generated HTML stored in a
<field>_html attribute on the record. We also store the version used for generating the markdown.
All other classes that include this model will include the
Gitlab::MarkdownCache::Redis::Extension. This add the
<field>_html attributes to that model and will generate the html in them. The generated HTML will be cached in redis under the key
markdown_cache:<cache_key>. The class this included in must therefore respond to
Does this MR meet the acceptance criteria?
- Changelog entry
- [-] Documentation created/updated or follow-up review issue created
- Code review guidelines
- Merge request performance guidelines
- Style guides
- Database guides
- [-] Separation of EE specific content
Performance and testing
- Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
- [-] Tested in all supported browsers
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Closes #54140 (closed)