semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

.Net: New Feature: Support synchronous construction for SqliteMemoryStore

Open f2bo opened this issue 1 year ago • 2 comments

SqliteMemoryStore implements IMemoryStore, where all its method are async, so I understand why its implemented this way even though Microsoft.Data.Sqlite does not recommend using asynchronous I/O.

SQLite doesn't support asynchronous I/O. Async ADO.NET methods will execute synchronously in Microsoft.Data.Sqlite. Avoid calling them.

However, its constructor is private and it can only be instantiaded asynchronously via its static ConnectAsync method, which makes it challenging to configure as a service in DI container or in an object pool. Moreover, given that ConnectAsync is not dictated by IMemoryStore, it would be useful to also include a Connect method, or some other means of constructing it synchronously.

f2bo avatar Aug 03 '24 20:08 f2bo

Hi @westey-m is this something we want to support with the new memory connector abstractions?

moonbox3 avatar Aug 05 '24 15:08 moonbox3

When implementing the SQLite implementation of the new memory connector abstractions we should definitely reconsider this. I don't think we necessarily need the connect method. There is a challenge around when to create tables, but it'll really depend on how we represent collections. That will need to be re-thinked quite a bit in the new system, since a goal is to support consuming data from existing stores, and not just ones created by our system.

westey-m avatar Aug 06 '24 14:08 westey-m

The new Sqlite VetorStore implementation allows synchronous construction. Recommendation is to switch to using it instead of the MemoryStore implementation.

westey-m avatar Oct 21 '24 08:10 westey-m