New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache rendered template #12
Comments
Hi @megafinz, yes you are right, it does it on each call. I will think about it, but you know - proper caching is hard. 😄 This would introduce some kind of state inside of library. I really need to think about it. Any help (even good idea) here is more then welcome. |
Doesn't partial application get you this "for free" ? e.g. use Fue.Compiler
use Fue.Data
let someTemplate: Map<String, object> -> string = fromFile "SomeTemplate.txt.fue"
let a = init |> add "name" "Bob" |> someTemplate
let b = init |> add "name" "Jones" |> someTemplate |
@petejohanson Not really. When you apply partial application, the function is not being executed, it's just becoming a function with an embedded param. It's the same as if you were passing that filename directly in each call. |
* Switch to not relying on auto-currying, but intentional pre-load/parse then return resulting template function, so we can partially apply fromText/fromFile and re-use the templates. Fixes Dzoukr#12.
@megafinz Indeed, the current implementation relying on auto-currying does not work as I had outlined. See my PR which adjusts things so that it does in fact work as expected w/ partial application creating a pre-loaded "template function" that can be re-used and won't re-load/parse the template string/file. |
PS: @Dzoukr thanks for a nice codebase that works OOTB when using .NET Core on Linux! |
PPS: Pondering this a tad more, you could argue, if weakly, that this is a breaking change in behaviour, if consumers of Fue previously relied on partial applications of |
Hi @petejohanson & @megafinz, I just merged changes from PR. Let me check few tests and we can publish new version. I agree with @petejohanson that it is subtle change and behavior should be actually like that from very beginning. |
Seems like Fue is compiling the template each time I call it (I'm using
fromText
), even if it doesn't change (except the data). This generates a lot of unneeded memory traffic which I'd like to avoid. Is there any way to reuse the compiled template?The text was updated successfully, but these errors were encountered: