RFC: Events and streams #761
colinodell
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Disclaimer: I'm jotting down a random idea I had today. I have not fully thought through the implications of this or how feasible it might be.
We currently perform some pre-processing on the Markdown input. For example:
These examples take the input, do some logic, and return an almost-similarly-sized amount of data back. With this in mind:
Events
What if we wanted to provide a caching extension? Such an extension may want to observe the
DocumentPreParsedEvent
to check the cache for the converted Markdown, but it has no way to tell this library to return any cached HTML immediately. We may want to take inspiration from Symfony'skernel.request
event which allows observers to not just pre-processing the incoming request but also allows them to short-circuit the usual process with a direct response. This would be a nice clean way to implement caching.Streams
The Markdown input comes in as a string. The pre-processing then creates modified copies of that string that are similar in size. Would using streams and generators under the hood help reduce memory overhead? Might be something to profile with Blackfire and see if there's any opportunity for improvement (I suspect maybe not, but you never know until you try)
Beta Was this translation helpful? Give feedback.
All reactions