How are templates in RazorEngine cached?

前端 未结 2 715
不思量自难忘°
不思量自难忘° 2021-02-13 20:20

When you call RazorEngine.Razor.Compile(), where is the compiled template stored?

Is it available after the programs been restarted? If there is a memory sh

2条回答
  •  时光说笑
    2021-02-13 20:32

    Currently, after the RazorEngine compiles the templates, they are loaded into memory. These assemblies persist in memory only and do not continue beyond the lifetime of the application.

    I am considering adding in support for compiling these assemblies to files, but that'll be a future version.

    If you call Razor.Parse and pass in a name for the template, it will attempt to

    1. Check the cache of in-memory assemblies for an assembly with the same name.
    2. Invalid the cache of the content of the template has changed.
    3. Cache the newly compiled template.

提交回复
热议问题