9e7f26f7a6
* Introduce ModelCacheManager to manage cache and sizes and deletions * move and abstract * add tests and format * Update src/Speckle.Sdk/Caching/ModelCacheManager.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Clean up --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
21 lines
758 B
C#
21 lines
758 B
C#
using Speckle.InterfaceGenerator;
|
|
using Speckle.Sdk.Caching;
|
|
using Speckle.Sdk.Logging;
|
|
|
|
namespace Speckle.Sdk.SQLite;
|
|
|
|
[GenerateAutoInterface]
|
|
public class SqLiteJsonCacheManagerFactory(IModelCacheManager modelCacheManager) : ISqLiteJsonCacheManagerFactory
|
|
{
|
|
public const int INITIAL_CONCURRENCY = 4;
|
|
|
|
private ISqLiteJsonCacheManager Create(string path, int concurrency) =>
|
|
SqLiteJsonCacheManager.FromFilePath(path, concurrency);
|
|
|
|
public ISqLiteJsonCacheManager CreateForUser(string scope) =>
|
|
Create(Path.Combine(SpecklePathProvider.UserApplicationDataPath(), "Speckle", $"{scope}.db"), 1);
|
|
|
|
public ISqLiteJsonCacheManager CreateFromStream(string streamId) =>
|
|
Create(modelCacheManager.GetStreamPath(streamId), INITIAL_CONCURRENCY);
|
|
}
|