Vault Hierarchy
| # | Layer | Interface / Class | Description |
|---|---|---|---|
| 1 | Persistence Provider | IGeneralDatabaseProvider | Directly interfaces with the database, offering basic CRUD operations. |
| 2 | Vault API | LinqVault / CqlVault | Abstracts the persistence layer. Chooses implementation based on storage type (EF Core / Scylla). |
| 3 | Vault Factory | VaultFactory | Internally creates the correct Vault API. Overridable for custom logic. |
| 4 | Vault Repository | VaultRepository | High-level interface exposed to developers. Organizes vaults by keyspace. |
Note:
💡 You can extend this setup with custom implementations at any level, but most users will only interact with the VaultRepository directly.
Example Usage
public class MyService {
public MyService(VaultRepository<MyKeySpace> myVaultRepository) {
var vault = myVaultRepository.Select<Player>();
}
}
Handling Multiple Databases
If your application must connect to multiple databases, avoid directly using VaultRepository<MyKeySpace>. Instead, use the RepositoryFactory:
public class MyService {
public MyService(RepositoryFactory myVaultRepository) {
var vaultRepo = myVaultRepository.Make<MyKeyspace>();
var vault = vaultRepo.Select<Player>();
}
}
This ensures correct repository selection and avoids ambiguity when working with multiple databases.
Note:
It is always advised to use the factory pattern over the direct pattern.
Summary
- Database Provider (
IGeneralDatabaseProvider) → Direct database interaction. - Vault API (
LinqVault/CqlVault) → EF Core vs Cassandra. - Vault Factory (
VaultFactory) → Constructs the correct vault instance. - Vault Repository (
VaultRepository) → Groups vaults under a keyspace. - Repository Factory (
RepositoryFactory) → Handles multiple databases effectively.
By understanding these layers, you can leverage the Vault API efficiently in your application.