Skip to content
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

Expression Cache in async multi-threaded environment #59

Open
codermrrob opened this issue Apr 3, 2020 · 1 comment
Open

Expression Cache in async multi-threaded environment #59

codermrrob opened this issue Apr 3, 2020 · 1 comment

Comments

@codermrrob
Copy link

codermrrob commented Apr 3, 2020

Sorry, not really a bug. I just need advice.

I would like to use Expressive in an async multi-threaded environment. Can you please let me know if the compiled expression cache is safe to use in this scenario?

I have run into this problem with NCalc and have to disable caching which is not ideal as I tend to have a high number of repeated expressions.

Regardless I will probably switch to Expressive now that I have found you guys.

Thank you for your efforts.

@bijington
Copy link
Owner

Hi @codermrrob

I do currently use Expressive in a multi-threaded environment however I do not currently cache the expressions. I do currently suspect there could be some edge cases where it could potentially fail however I am happy to address these.

Some potential issues or points are:

  1. The main edge case is around when the expression is compiled and the lack of any kind of locking. This is an easy fix though.
  2. Another point to note is that currently some keywords such as #now# or #today# are evaluated when the expression is compiled and not re-evaluated each time the expression is evaluated. This is the main reason that I do not currently cache the expressions and I cannot seem to decide if this is correct behaviour or not.
  3. I have also been considering adding in direct support for the TPL (e.g. async/await). Is this what you are referring to with an async multi-threaded environment and do you think it would be of value?
  4. Are you able to explain what the issues are that you have seen with NCalc? They could well be pitfalls we have also fallen in to on this project but always happy to fix and learn :).

And thank you for considering to use Expressive :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants