mirror of
https://github.com/harness/drone.git
synced 2025-05-05 02:02:14 +08:00

This change is a follow up on the effort to remove transactions and sync stores from the database layer, and move them in the application layer. It is addressing the repo + space store. The following changes are included: - Introduce PathStore storing resource paths (repo + space) - Add foreign key from path.repo_id/space_id to repo.id/space.id - Add foreign key from repo/space.parent_id to space.id - Remove repo_sync and space_sync - Move path creation logic to repo/space controller (for both creating primary paths for new repos/spaces, as well as creating alias spaces) - Reimplement repo/space moving on controller layer
37 lines
1015 B
Go
37 lines
1015 B
Go
// Copyright 2022 Harness Inc. All rights reserved.
|
|
// Use of this source code is governed by the Polyform Free Trial License
|
|
// that can be found in the LICENSE.md file for this repository.
|
|
|
|
package cache
|
|
|
|
import (
|
|
"context"
|
|
|
|
"golang.org/x/exp/constraints"
|
|
)
|
|
|
|
// Cache is an abstraction of a simple cache.
|
|
type Cache[K constraints.Ordered, V Identifiable[K]] interface {
|
|
Stats() (int64, int64)
|
|
Get(ctx context.Context, key K) (V, error)
|
|
}
|
|
|
|
// ExtendedCache is an extension of the simple cache abstraction that adds mapping functionality.
|
|
type ExtendedCache[K constraints.Ordered, V Identifiable[K]] interface {
|
|
Cache[K, V]
|
|
Map(ctx context.Context, keys []K) (map[K]V, error)
|
|
}
|
|
|
|
type Identifiable[K constraints.Ordered] interface {
|
|
Identifier() K
|
|
}
|
|
|
|
type Getter[K constraints.Ordered, V Identifiable[K]] interface {
|
|
Find(ctx context.Context, key K) (V, error)
|
|
}
|
|
|
|
type ExtendedGetter[K constraints.Ordered, V Identifiable[K]] interface {
|
|
Getter[K, V]
|
|
FindMany(ctx context.Context, keys []K) ([]V, error)
|
|
}
|