Skip to content

Commit

Permalink
perf: use custom cache key that calculated by diagram type and source
Browse files Browse the repository at this point in the history
Closes #12
  • Loading branch information
razonyang committed Jun 8, 2024
1 parent 0f1a3f7 commit ebdd269
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion layouts/partials/kroki/functions/svg.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
{{- if not $ctx.type }}
{{- errorf "[kroki] %s" "no diagram type specified" }}
{{- end }}
{{- $type := $ctx.type | lower }}
{{- $body := dict
"diagram_source" $ctx.source
"diagram_type" ($ctx.type | lower)
"diagram_type" $type
"output_format" "svg"
}}
{{- $cacheKey := printf "kroki-%s-%s" $type ($ctx.source | md5) }}
{{- $opts := dict
"key" $cacheKey
"method" "post"
"body" ($body | jsonify)
"headers" (dict
Expand Down

0 comments on commit ebdd269

Please sign in to comment.