r2dbc-mssql icon indicating copy to clipboard operation
r2dbc-mssql copied to clipboard

Add support for configuring PreparedStatementCache

Open vijayakumarsuraj opened this issue 3 years ago • 2 comments

Make sure that:

  • [x] You have read the contribution guidelines.
  • [x] You have created a feature request first to discuss your contribution intent. Please reference the feature request ticket number in the pull request.
  • [x] You use the code formatters provided here and have them applied to your changes. Don't submit any formatting related changes.
  • [x] You submit test cases (unit or integration tests) that back your changes.

Issue description

https://github.com/r2dbc/r2dbc-mssql/issues/227 - Allow configuring the prepared statement cache

New Public APIs

  • PreparedStatementCache is now public.
  • Added discovery option preparedStatementCache.

Additional context

The preparedStatementCache discovery option behaves similar to the one in r2dbc-postgresql.

  • -1 = indefinite cache
  • 0 = no cache
  • n = LRU cache with max size n.
  • Additionally, it also accepts the class name of a PreparedStatementCache implementation.

vijayakumarsuraj avatar Nov 11 '21 19:11 vijayakumarsuraj

Thanks a lot. For a proper implementation of the cache we need to call sp_unprepare <handle> somewhere, ideally when the cache entry is being removed. Calling unprepare can interfere with the ongoing query so that might require some special attention.

mp911de avatar Nov 12 '21 10:11 mp911de

For now, can we provide only NoPreparedStatementCache to allow disabling cache ? If it is ok i can create new PR.

xnart avatar May 08 '22 14:05 xnart