feat: implement repository architecture with smart caching
- Add base repository interfaces and abstract classes - Implement separated read/write repositories for Domain and Username models - Add intelligent query caching with automatic invalidation - Include cache management service and CLI commands - Add comprehensive configuration for cache TTL and monitoring - Enhance performance through optimized data access patterns
This commit is contained in:
52
app/Repositories/Contracts/ReadRepositoryInterface.php
Normal file
52
app/Repositories/Contracts/ReadRepositoryInterface.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Contracts;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
interface ReadRepositoryInterface
|
||||
{
|
||||
public function findById(int $id, array $columns = ['*']): ?Model;
|
||||
|
||||
public function findBy(string $column, mixed $value, array $columns = ['*']): ?Model;
|
||||
|
||||
public function all(array $columns = ['*']): Collection;
|
||||
|
||||
public function get(array $columns = ['*']): Collection;
|
||||
|
||||
public function paginate(int $perPage = 15, array $columns = ['*'], string $pageName = 'page'): LengthAwarePaginator;
|
||||
|
||||
public function whereIn(string $column, array $values, array $columns = ['*']): Collection;
|
||||
|
||||
public function where(string $column, mixed $operator, mixed $value = null): self;
|
||||
|
||||
public function whereNull(string $column): self;
|
||||
|
||||
public function whereNotNull(string $column): self;
|
||||
|
||||
public function whereBetween(string $column, array $values): self;
|
||||
|
||||
public function orderBy(string $column, string $direction = 'asc'): self;
|
||||
|
||||
public function limit(int $limit): self;
|
||||
|
||||
public function with(array $relations): self;
|
||||
|
||||
public function withCount(array $relations): self;
|
||||
|
||||
public function exists(): bool;
|
||||
|
||||
public function count(): int;
|
||||
|
||||
public function first(array $columns = ['*']): ?Model;
|
||||
|
||||
public function firstWhere(string $column, mixed $operator, mixed $value = null): ?Model;
|
||||
|
||||
public function pluck(string $column, ?string $key = null): Collection;
|
||||
|
||||
public function clearCache(): void;
|
||||
|
||||
public function clearCacheForModel(Model $model): void;
|
||||
}
|
||||
Reference in New Issue
Block a user