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

Add InMemory Cache Provider #51

Merged
merged 4 commits into from
Feb 25, 2025
Merged

Add InMemory Cache Provider #51

merged 4 commits into from
Feb 25, 2025

Conversation

Axemasta
Copy link
Owner

Currently Mocale HAS to be used with the SQLite cache provider unless you roll your own caching solution. I've finally implemented a very basic in memory cache system so when external localizations are fetched they'll stick in memory for the lifetime of the application.

This has the downside of everytime you run the app it needs to call out to refresh the localizations however it means people using local cache only can have mocale run without the need to persist any data!

This PR also kicks the ball off for testing the app builder elements, I will do more in a seperate PR for the various config points in the library!

Theres nothing fancy about this, I've added the ability to use Mocale without SQL Caching. This is a very basic app lifetime cache, but should do the trick!
Added tests for the in mem cache class aswell as the app builder. This is the first foray into an integration style test to make sure the logic in the app builder is sound, so far so good I'll get the rest tested!
The main solution was struggling, I've fixed it now
The dotnet cli really wants to miss whats right infront of its eyes!
Copy link

File Coverage Lines Branches Missing
All files 32% 33% 32%
Mocale.Cache.SQLite\obj\Release\net9.0\Microsoft.Maui.Controls.BindingSourceGen\Microsoft.Maui.Controls.BindingSourceGen.BindingSourceGenerator\GeneratedBindingInterceptorsCommon.g.cs 0% 0% 0% 19-28
Mocale.Cache.SQLite\MocaleBuilderExtension.cs 96% 93% 100% 21
Mocale.Cache.SQLite\Repositories\CacheRepository.cs 0% 0% 0% 13-93
Mocale.Cache.SQLite\Repositories\RepositoryBase.cs 0% 0% 100% 8-21
Mocale.Cache.SQLite\Repositories\TranslationsRepository.cs 0% 0% 0% 12-163
Mocale.Cache.SQLite\Providers\DatabaseConnectionProvider.cs 0% 0% 100% 16-49
Mocale.Cache.SQLite\Providers\DatabasePathProvider.cs 0% 0% 100% 4-13
Mocale.Cache.SQLite\Managers\LocalisationCacheManager.cs 0% 0% 0% 6-44
Mocale.Cache.SQLite\Managers\SqlCacheUpdateManager.cs 0% 0% 0% 15-78
Mocale.Cache.SQLite\Entities\TranslationItem.cs 0% 0% 100% 10-16
Mocale.Cache.SQLite\Entities\UpdateHistoryItem.cs 0% 0% 100% 10-14
Mocale\obj\Release\net9.0\Microsoft.Maui.Controls.BindingSourceGen\Microsoft.Maui.Controls.BindingSourceGen.BindingSourceGenerator\GeneratedBindingInterceptorsCommon.g.cs 0% 0% 0% 19-28
Mocale\MocaleBuilder.cs 66% 83% 50% 12 28
Mocale\MocaleBuilderExtensions.cs 24% 31% 16% 22-34 65 70 80-119
Mocale\MocaleInitializeService.cs 0% 0% 100% 7-15
Mocale\MocaleLocator.cs 87% 75% 100% 33
Mocale\Wrappers\DateTimeWrapper.cs 0% 0% 100% 10
Mocale\Providers\EmbeddedResourceProvider.cs 88% 94% 83% 72-73
Mocale\Providers\InactiveExternalLocalizationProvider.cs 0% 0% 100% 8-13
Mocale\Providers\ResxResourceProvider.cs 0% 0% 0% 14-65
Mocale\Parsers\ResxLocalizationParser.cs 87% 100% 75%
Mocale\Models\AppResourcesConfig.cs 0% 0% 100% 7
Mocale\Models\EmbeddedResourcesConfig.cs 83% 66% 100% 11
Mocale\Models\LocalizeEnumBehavior.cs 0% 0% 100% 39-49
Mocale\Models\ResxResourceFileDetails.cs 87% 75% 100% 9
Mocale\Managers\ParameterTranslatorManager.cs 0% 0% 0% 13-57
Mocale\Managers\TranslationResolver.cs 0% 0% 0% 5-167
Mocale\Managers\TranslationResolver.cs 0% 0% 100% 91-104
Mocale\Managers\TranslationResolver.cs 0% 0% 0% 27-80
Mocale\Managers\TranslatorManager.cs 80% 76% 85% 75-91 146-147
Mocale\Helper\EnumTranslationKeyHelper.cs 0% 0% 0% 5-35
Mocale\Helper\EnumTranslationKeyHelper.cs 0% 0% 0% 43-67
Mocale\Extensions\BindableObjectExtension.cs 16% 13% 20% 21-81 102 114 133-187
Mocale\Extensions\DictionaryExtension.cs 95% 100% 90%
Mocale\Extensions\LocalizeBindingExtension.cs 0% 0% 0% 13-93
Mocale\Extensions\LocalizeEnumExtension.cs 0% 0% 0% 14-92
Mocale\Extensions\LocalizeExtension.cs 0% 0% 0% 13-103
Mocale\Extensions\LocalizeExtension.cs 0% 0% 0% 110-120
Mocale\Extensions\LocalizeMultiBindingExtension.cs 0% 0% 0% 13-98
Mocale\Extensions\TaskExtensions.cs 87% 100% 75%
Mocale\Extensions\UriExtension.cs 57% 14% 100% 13-25
Mocale\Exceptions\MocaleException.cs 75% 50% 100% 11-13
Mocale.Providers.AWS.S3\obj\Release\net9.0\Microsoft.Maui.Controls.BindingSourceGen\Microsoft.Maui.Controls.BindingSourceGen.BindingSourceGenerator\GeneratedBindingInterceptorsCommon.g.cs 0% 0% 0% 19-28
Mocale.Providers.AWS.S3\MocaleBuilderExtension.cs 0% 0% 100% 18-28
Mocale.Providers.AWS.S3\S3BucketProvider.cs 0% 0% 0% 9-46
Mocale.Providers.AWS.S3\Models\BucketConfig.cs 0% 0% 100% 7-10
Mocale.Providers.Azure.Blob\obj\Release\net9.0\Microsoft.Maui.Controls.BindingSourceGen\Microsoft.Maui.Controls.BindingSourceGen.BindingSourceGenerator\GeneratedBindingInterceptorsCommon.g.cs 0% 0% 0% 19-28
Mocale.Providers.Azure.Blob\BlobLocalizationProvider.cs 0% 0% 100% 15-35
Mocale.Providers.Azure.Blob\BlobLocalizationProvider.cs 0% 0% 0% 45-69
Mocale.Providers.Azure.Blob\BlobLocalizationProvider.cs 0% 0% 0% 100-130
Mocale.Providers.Azure.Blob\BlobLocalizationProvider.cs 0% 0% 0% 75-92
Mocale.Providers.Azure.Blob\MocaleBuilderExtension.cs 0% 0% 0% 20-33
Mocale.Providers.Azure.Blob\Models\BlobResourceInfo.cs 0% 0% 100% 11-16
Mocale.Providers.Azure.Blob\Models\BlobStorageConfig.cs 0% 0% 100% 7-16
Mocale.Providers.Azure.Blob\Managers\BlobResourceLocator.cs 0% 0% 0% 15-52
Mocale.Providers.Azure.Blob\Managers\BlobResourceLocator.cs 0% 0% 0% 63-86
Mocale.Providers.Github.Raw\obj\Release\net9.0\Microsoft.Maui.Controls.BindingSourceGen\Microsoft.Maui.Controls.BindingSourceGen.BindingSourceGenerator\GeneratedBindingInterceptorsCommon.g.cs 0% 0% 0% 19-28
Mocale.Providers.Github.Raw\GitHubRawProvider.cs 52% 39% 66% 48-53 62-67 75-83
Mocale.Providers.Github.Raw\MocaleBuilderExtension.cs 0% 0% 0% 18-34
Mocale.Testing\obj\Release\net9.0\Microsoft.Maui.Controls.BindingSourceGen\Microsoft.Maui.Controls.BindingSourceGen.BindingSourceGenerator\GeneratedBindingInterceptorsCommon.g.cs 0% 0% 0% 19-28
Mocale.Testing\TranslatorManagerProxy.cs 78% 78% 77% 26 33 38 51 58-60
Mocale.Testing\Extensions\DictionaryExtension.cs 72% 84% 60% 25-27

Minimum allowed coverage is 5%

Generated by 🐒 cobertura-action against df9ed70

@Axemasta Axemasta merged commit 61b7fb6 into main Feb 25, 2025
4 checks passed
@Axemasta Axemasta deleted the feature/memory-cache branch March 4, 2025 01:08
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

Successfully merging this pull request may close these issues.

1 participant