-
- Downloads
There was an error fetching the commit references. Please try again later.
Use Redis for CacheMarkDownField on non AR models
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:<class>:<id>`. The class this included in must therefore respond to `id`.
Showing
- app/models/commit.rb 4 additions, 7 deletionsapp/models/commit.rb
- app/models/concerns/cache_markdown_field.rb 16 additions, 72 deletionsapp/models/concerns/cache_markdown_field.rb
- changelogs/unreleased/54140-non-ar-cache-commit-markdown.yml 5 additions, 0 deletionschangelogs/unreleased/54140-non-ar-cache-commit-markdown.yml
- lib/banzai/commit_renderer.rb 1 addition, 1 deletionlib/banzai/commit_renderer.rb
- lib/gitlab/markdown_cache.rb 12 additions, 0 deletionslib/gitlab/markdown_cache.rb
- lib/gitlab/markdown_cache/active_record/extension.rb 55 additions, 0 deletionslib/gitlab/markdown_cache/active_record/extension.rb
- lib/gitlab/markdown_cache/field_data.rb 35 additions, 0 deletionslib/gitlab/markdown_cache/field_data.rb
- lib/gitlab/markdown_cache/redis/extension.rb 63 additions, 0 deletionslib/gitlab/markdown_cache/redis/extension.rb
- lib/gitlab/markdown_cache/redis/store.rb 56 additions, 0 deletionslib/gitlab/markdown_cache/redis/store.rb
- spec/features/markdown/gitlab_flavored_markdown_spec.rb 1 addition, 2 deletionsspec/features/markdown/gitlab_flavored_markdown_spec.rb
- spec/helpers/markup_helper_spec.rb 2 additions, 1 deletionspec/helpers/markup_helper_spec.rb
- spec/lib/banzai/commit_renderer_spec.rb 2 additions, 2 deletionsspec/lib/banzai/commit_renderer_spec.rb
- spec/lib/banzai/object_renderer_spec.rb 21 additions, 7 deletionsspec/lib/banzai/object_renderer_spec.rb
- spec/lib/banzai/renderer_spec.rb 11 additions, 3 deletionsspec/lib/banzai/renderer_spec.rb
- spec/lib/gitlab/markdown_cache/active_record/extension_spec.rb 177 additions, 0 deletions...lib/gitlab/markdown_cache/active_record/extension_spec.rb
- spec/lib/gitlab/markdown_cache/field_data_spec.rb 15 additions, 0 deletionsspec/lib/gitlab/markdown_cache/field_data_spec.rb
- spec/lib/gitlab/markdown_cache/redis/extension_spec.rb 76 additions, 0 deletionsspec/lib/gitlab/markdown_cache/redis/extension_spec.rb
- spec/lib/gitlab/markdown_cache/redis/store_spec.rb 68 additions, 0 deletionsspec/lib/gitlab/markdown_cache/redis/store_spec.rb
- spec/models/concerns/cache_markdown_field_spec.rb 138 additions, 308 deletionsspec/models/concerns/cache_markdown_field_spec.rb
- spec/models/resource_label_event_spec.rb 2 additions, 2 deletionsspec/models/resource_label_event_spec.rb
lib/gitlab/markdown_cache.rb
0 → 100644
lib/gitlab/markdown_cache/field_data.rb
0 → 100644
lib/gitlab/markdown_cache/redis/extension.rb
0 → 100644
lib/gitlab/markdown_cache/redis/store.rb
0 → 100644
Please register or sign in to comment