redis

package
v0.0.0-...-bf444b6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnexpectedCachedResource = errors.New("unexpected cached resource") // received cache resource was not expected

Functions

func NewClient

func NewClient(conf *config.CacheDatabaseConfig) (redis.UniversalClient, error)

NewClient creates a new Redis client.

Types

type CacheBackend

type CacheBackend interface {
	Set(item *cache.Item) error
	Get(ctx context.Context, key string, dst any) error
	Delete(ctx context.Context, key string) error
}

CacheBackend represents a cache backend.

type CachedAssignmentRepository

type CachedAssignmentRepository struct {
	// contains filtered or unexported fields
}

CachedAssignmentRepository implements caching on the repository.AssignmentRepository.

func NewCachedAssignmentRepository

func NewCachedAssignmentRepository(repo repository.AssignmentRepository, opts ...RepositoryOption) (*CachedAssignmentRepository, error)

NewCachedAssignmentRepository returns a new CachedAssignmentRepository.

func (*CachedAssignmentRepository) Create

func (r *CachedAssignmentRepository) Create(ctx context.Context, assignment *model.Assignment) error

func (*CachedAssignmentRepository) Delete

func (*CachedAssignmentRepository) Get

func (*CachedAssignmentRepository) GetByResource

func (r *CachedAssignmentRepository) GetByResource(ctx context.Context, resourceID model.ID, offset, limit int) ([]*model.Assignment, error)

func (*CachedAssignmentRepository) GetByUser

func (r *CachedAssignmentRepository) GetByUser(ctx context.Context, userID model.ID, offset, limit int) ([]*model.Assignment, error)

type CachedAttachmentRepository

type CachedAttachmentRepository struct {
	// contains filtered or unexported fields
}

CachedAttachmentRepository implements caching on the repository.AttachmentRepository.

func NewCachedAttachmentRepository

func NewCachedAttachmentRepository(repo repository.AttachmentRepository, opts ...RepositoryOption) (*CachedAttachmentRepository, error)

NewCachedAttachmentRepository returns a new CachedAttachmentRepository.

func (*CachedAttachmentRepository) Create

func (r *CachedAttachmentRepository) Create(ctx context.Context, belongsTo model.ID, attachment *model.Attachment) error

func (*CachedAttachmentRepository) Delete

func (*CachedAttachmentRepository) Get

func (*CachedAttachmentRepository) GetAllBelongsTo

func (r *CachedAttachmentRepository) GetAllBelongsTo(ctx context.Context, belongsTo model.ID, offset, limit int) ([]*model.Attachment, error)

func (*CachedAttachmentRepository) Update

type CachedCommentRepository

type CachedCommentRepository struct {
	// contains filtered or unexported fields
}

CachedCommentRepository implements caching on the repository.CommentRepository.

func NewCachedCommentRepository

func NewCachedCommentRepository(repo repository.CommentRepository, opts ...RepositoryOption) (*CachedCommentRepository, error)

NewCachedCommentRepository returns a new CachedCommentRepository.

func (*CachedCommentRepository) Create

func (r *CachedCommentRepository) Create(ctx context.Context, belongsTo model.ID, comment *model.Comment) error

func (*CachedCommentRepository) Delete

func (r *CachedCommentRepository) Delete(ctx context.Context, id model.ID) error

func (*CachedCommentRepository) Get

func (*CachedCommentRepository) GetAllBelongsTo

func (r *CachedCommentRepository) GetAllBelongsTo(ctx context.Context, belongsTo model.ID, offset, limit int) ([]*model.Comment, error)

func (*CachedCommentRepository) Update

func (r *CachedCommentRepository) Update(ctx context.Context, id model.ID, content string) (*model.Comment, error)

type CachedDocumentRepository

type CachedDocumentRepository struct {
	// contains filtered or unexported fields
}

CachedDocumentRepository implements caching on the repository.DocumentRepository.

func NewCachedDocumentRepository

func NewCachedDocumentRepository(repo repository.DocumentRepository, opts ...RepositoryOption) (*CachedDocumentRepository, error)

NewCachedDocumentRepository returns a new CachedDocumentRepository.

func (*CachedDocumentRepository) Create

func (r *CachedDocumentRepository) Create(ctx context.Context, belongsTo model.ID, document *model.Document) error

func (*CachedDocumentRepository) Delete

func (*CachedDocumentRepository) Get

func (*CachedDocumentRepository) GetAllBelongsTo

func (r *CachedDocumentRepository) GetAllBelongsTo(ctx context.Context, belongsTo model.ID, offset, limit int) ([]*model.Document, error)

func (*CachedDocumentRepository) GetByCreator

func (r *CachedDocumentRepository) GetByCreator(ctx context.Context, createdBy model.ID, offset, limit int) ([]*model.Document, error)

func (*CachedDocumentRepository) Update

func (r *CachedDocumentRepository) Update(ctx context.Context, id model.ID, patch map[string]any) (*model.Document, error)

type CachedIssueRepository

type CachedIssueRepository struct {
	// contains filtered or unexported fields
}

CachedIssueRepository implements caching on the repository.IssueRepository.

func NewCachedIssueRepository

func NewCachedIssueRepository(repo repository.IssueRepository, opts ...RepositoryOption) (*CachedIssueRepository, error)

NewCachedIssueRepository returns a new CachedIssueRepository.

func (*CachedIssueRepository) AddRelation

func (r *CachedIssueRepository) AddRelation(ctx context.Context, relation *model.IssueRelation) error

func (*CachedIssueRepository) AddWatcher

func (r *CachedIssueRepository) AddWatcher(ctx context.Context, issue model.ID, user model.ID) error

func (*CachedIssueRepository) Create

func (r *CachedIssueRepository) Create(ctx context.Context, project model.ID, issue *model.Issue) error

func (*CachedIssueRepository) Delete

func (r *CachedIssueRepository) Delete(ctx context.Context, id model.ID) error

func (*CachedIssueRepository) Get

func (*CachedIssueRepository) GetAllForIssue

func (r *CachedIssueRepository) GetAllForIssue(ctx context.Context, issueID model.ID, offset, limit int) ([]*model.Issue, error)

func (*CachedIssueRepository) GetAllForProject

func (r *CachedIssueRepository) GetAllForProject(ctx context.Context, projectID model.ID, offset, limit int) ([]*model.Issue, error)

func (*CachedIssueRepository) GetRelations

func (r *CachedIssueRepository) GetRelations(ctx context.Context, issue model.ID) ([]*model.IssueRelation, error)

func (*CachedIssueRepository) GetWatchers

func (r *CachedIssueRepository) GetWatchers(ctx context.Context, issue model.ID) ([]*model.User, error)

func (*CachedIssueRepository) RemoveRelation

func (r *CachedIssueRepository) RemoveRelation(ctx context.Context, source, target model.ID, kind model.IssueRelationKind) error

func (*CachedIssueRepository) RemoveWatcher

func (r *CachedIssueRepository) RemoveWatcher(ctx context.Context, issue model.ID, user model.ID) error

func (*CachedIssueRepository) Update

func (r *CachedIssueRepository) Update(ctx context.Context, id model.ID, patch map[string]any) (*model.Issue, error)

type CachedLabelRepository

type CachedLabelRepository struct {
	// contains filtered or unexported fields
}

CachedLabelRepository implements caching on the repository.LabelRepository.

func NewCachedLabelRepository

func NewCachedLabelRepository(repo repository.LabelRepository, opts ...RepositoryOption) (*CachedLabelRepository, error)

NewCachedLabelRepository returns a new CachedLabelRepository.

func (*CachedLabelRepository) AttachTo

func (r *CachedLabelRepository) AttachTo(ctx context.Context, labelID, attachTo model.ID) error

func (*CachedLabelRepository) Create

func (r *CachedLabelRepository) Create(ctx context.Context, label *model.Label) error

func (*CachedLabelRepository) Delete

func (r *CachedLabelRepository) Delete(ctx context.Context, id model.ID) error

func (*CachedLabelRepository) DetachFrom

func (r *CachedLabelRepository) DetachFrom(ctx context.Context, labelID, detachFrom model.ID) error

func (*CachedLabelRepository) Get

func (*CachedLabelRepository) GetAll

func (r *CachedLabelRepository) GetAll(ctx context.Context, offset, limit int) ([]*model.Label, error)

func (*CachedLabelRepository) Update

func (r *CachedLabelRepository) Update(ctx context.Context, id model.ID, patch map[string]any) (*model.Label, error)

type CachedNamespaceRepository

type CachedNamespaceRepository struct {
	// contains filtered or unexported fields
}

CachedNamespaceRepository implements caching on the repository.NamespaceRepository.

func NewCachedNamespaceRepository

func NewCachedNamespaceRepository(repo repository.NamespaceRepository, opts ...RepositoryOption) (*CachedNamespaceRepository, error)

NewCachedNamespaceRepository returns a new CachedNamespaceRepository.

func (*CachedNamespaceRepository) Create

func (r *CachedNamespaceRepository) Create(ctx context.Context, orgID model.ID, namespace *model.Namespace) error

func (*CachedNamespaceRepository) Delete

func (*CachedNamespaceRepository) Get

func (*CachedNamespaceRepository) GetAll

func (r *CachedNamespaceRepository) GetAll(ctx context.Context, orgID model.ID, offset, limit int) ([]*model.Namespace, error)

func (*CachedNamespaceRepository) Update

func (r *CachedNamespaceRepository) Update(ctx context.Context, id model.ID, patch map[string]any) (*model.Namespace, error)

type CachedNotificationRepository

type CachedNotificationRepository struct {
	// contains filtered or unexported fields
}

CachedNotificationRepository implements caching on the repository.NotificationRepository.

func NewCachedNotificationRepository

func NewCachedNotificationRepository(repo repository.NotificationRepository, opts ...RepositoryOption) (*CachedNotificationRepository, error)

NewCachedNotificationRepository returns a new CachedNotificationRepository.

func (*CachedNotificationRepository) Create

func (r *CachedNotificationRepository) Create(ctx context.Context, notification *model.Notification) error

func (*CachedNotificationRepository) Delete

func (r *CachedNotificationRepository) Delete(ctx context.Context, id, recipient model.ID) error

func (*CachedNotificationRepository) Get

func (*CachedNotificationRepository) GetAllByRecipient

func (r *CachedNotificationRepository) GetAllByRecipient(ctx context.Context, recipient model.ID, offset, limit int) ([]*model.Notification, error)

func (*CachedNotificationRepository) Update

func (r *CachedNotificationRepository) Update(ctx context.Context, id, recipient model.ID, read bool) (*model.Notification, error)

type CachedOrganizationRepository

type CachedOrganizationRepository struct {
	// contains filtered or unexported fields
}

CachedOrganizationRepository implements caching on the repository.OrganizationRepository.

func NewCachedOrganizationRepository

func NewCachedOrganizationRepository(repo repository.OrganizationRepository, opts ...RepositoryOption) (*CachedOrganizationRepository, error)

NewCachedOrganizationRepository returns a new CachedOrganizationRepository.

func (*CachedOrganizationRepository) AddMember

func (r *CachedOrganizationRepository) AddMember(ctx context.Context, orgID, memberID model.ID) error

func (*CachedOrganizationRepository) Create

func (r *CachedOrganizationRepository) Create(ctx context.Context, owner model.ID, organization *model.Organization) error

func (*CachedOrganizationRepository) Delete

func (*CachedOrganizationRepository) Get

func (*CachedOrganizationRepository) GetAll

func (r *CachedOrganizationRepository) GetAll(ctx context.Context, offset, limit int) ([]*model.Organization, error)

func (*CachedOrganizationRepository) RemoveMember

func (r *CachedOrganizationRepository) RemoveMember(ctx context.Context, orgID, memberID model.ID) error

func (*CachedOrganizationRepository) Update

type CachedPermissionRepository

type CachedPermissionRepository struct {
	// contains filtered or unexported fields
}

CachedPermissionRepository implements cache clearing on resources that are related dependent on permission changes. This repository does not cache any data to prevent stale permission data. This repository mostly acts as a proxy to the permission repository and clears the cache on any changes.

Adding permission caching could be a future improvement, but that's a double-edged sword. It would be a performance improvement, but it would also mean that stale data could be cached.

func NewCachedPermissionRepository

func NewCachedPermissionRepository(repo repository.PermissionRepository, opts ...RepositoryOption) (*CachedPermissionRepository, error)

NewCachedPermissionRepository returns a new CachedPermissionRepository.

func (*CachedPermissionRepository) Create

func (*CachedPermissionRepository) Delete

func (*CachedPermissionRepository) Get

func (*CachedPermissionRepository) GetBySubject

func (c *CachedPermissionRepository) GetBySubject(ctx context.Context, id model.ID) ([]*model.Permission, error)

func (*CachedPermissionRepository) GetBySubjectAndTarget

func (c *CachedPermissionRepository) GetBySubjectAndTarget(ctx context.Context, source, target model.ID) ([]*model.Permission, error)

func (*CachedPermissionRepository) GetByTarget

func (c *CachedPermissionRepository) GetByTarget(ctx context.Context, id model.ID) ([]*model.Permission, error)

func (*CachedPermissionRepository) HasAnyRelation

func (c *CachedPermissionRepository) HasAnyRelation(ctx context.Context, source, target model.ID) (bool, error)

func (*CachedPermissionRepository) HasPermission

func (c *CachedPermissionRepository) HasPermission(ctx context.Context, subject, target model.ID, kinds ...model.PermissionKind) (bool, error)

func (*CachedPermissionRepository) HasSystemRole

func (c *CachedPermissionRepository) HasSystemRole(ctx context.Context, source model.ID, roles ...model.SystemRole) (bool, error)

func (*CachedPermissionRepository) Update

type CachedProjectRepository

type CachedProjectRepository struct {
	// contains filtered or unexported fields
}

CachedProjectRepository implements caching on the repository.ProjectRepository.

func NewCachedProjectRepository

func NewCachedProjectRepository(repo repository.ProjectRepository, opts ...RepositoryOption) (*CachedProjectRepository, error)

NewCachedProjectRepository returns a new CachedProjectRepository.

func (*CachedProjectRepository) Create

func (r *CachedProjectRepository) Create(ctx context.Context, namespaceID model.ID, project *model.Project) error

func (*CachedProjectRepository) Delete

func (r *CachedProjectRepository) Delete(ctx context.Context, id model.ID) error

func (*CachedProjectRepository) Get

func (*CachedProjectRepository) GetAll

func (r *CachedProjectRepository) GetAll(ctx context.Context, namespaceID model.ID, offset, limit int) ([]*model.Project, error)

func (*CachedProjectRepository) GetByKey

func (r *CachedProjectRepository) GetByKey(ctx context.Context, key string) (*model.Project, error)

func (*CachedProjectRepository) Update

func (r *CachedProjectRepository) Update(ctx context.Context, id model.ID, patch map[string]any) (*model.Project, error)

type CachedRoleRepository

type CachedRoleRepository struct {
	// contains filtered or unexported fields
}

CachedRoleRepository implements caching on the repository.RoleRepository.

func NewCachedRoleRepository

func NewCachedRoleRepository(repo repository.RoleRepository, opts ...RepositoryOption) (*CachedRoleRepository, error)

NewCachedRoleRepository returns a new CachedRoleRepository.

func (*CachedRoleRepository) AddMember

func (r *CachedRoleRepository) AddMember(ctx context.Context, roleID, memberID, belongsToID model.ID) error

func (*CachedRoleRepository) Create

func (r *CachedRoleRepository) Create(ctx context.Context, createdBy, belongsTo model.ID, role *model.Role) error

func (*CachedRoleRepository) Delete

func (r *CachedRoleRepository) Delete(ctx context.Context, id, belongsTo model.ID) error

func (*CachedRoleRepository) Get

func (r *CachedRoleRepository) Get(ctx context.Context, id, belongsTo model.ID) (*model.Role, error)

func (*CachedRoleRepository) GetAllBelongsTo

func (r *CachedRoleRepository) GetAllBelongsTo(ctx context.Context, belongsTo model.ID, offset, limit int) ([]*model.Role, error)

func (*CachedRoleRepository) RemoveMember

func (r *CachedRoleRepository) RemoveMember(ctx context.Context, roleID, memberID, belongsToID model.ID) error

func (*CachedRoleRepository) Update

func (r *CachedRoleRepository) Update(ctx context.Context, id, belongsTo model.ID, patch map[string]any) (*model.Role, error)

type CachedTodoRepository

type CachedTodoRepository struct {
	// contains filtered or unexported fields
}

CachedTodoRepository is implements caching on the repository.TodoRepository.

func NewCachedTodoRepository

func NewCachedTodoRepository(repo repository.TodoRepository, opts ...RepositoryOption) (*CachedTodoRepository, error)

NewCachedTodoRepository returns a new CachedTodoRepository.

func (*CachedTodoRepository) Create

func (r *CachedTodoRepository) Create(ctx context.Context, todo *model.Todo) error

func (*CachedTodoRepository) Delete

func (r *CachedTodoRepository) Delete(ctx context.Context, id model.ID) error

func (*CachedTodoRepository) Get

func (*CachedTodoRepository) GetByOwner

func (r *CachedTodoRepository) GetByOwner(ctx context.Context, ownerID model.ID, offset, limit int, completed *bool) ([]*model.Todo, error)

func (*CachedTodoRepository) Update

func (r *CachedTodoRepository) Update(ctx context.Context, id model.ID, patch map[string]any) (*model.Todo, error)

type CachedUserRepository

type CachedUserRepository struct {
	// contains filtered or unexported fields
}

CachedUserRepository implements caching on the repository.UserRepository.

func NewCachedUserRepository

func NewCachedUserRepository(repo repository.UserRepository, opts ...RepositoryOption) (*CachedUserRepository, error)

NewCachedUserRepository returns a new CachedUserRepository.

func (*CachedUserRepository) Create

func (r *CachedUserRepository) Create(ctx context.Context, user *model.User) error

func (*CachedUserRepository) Delete

func (r *CachedUserRepository) Delete(ctx context.Context, id model.ID) error

func (*CachedUserRepository) Get

func (*CachedUserRepository) GetAll

func (r *CachedUserRepository) GetAll(ctx context.Context, offset, limit int) ([]*model.User, error)

func (*CachedUserRepository) GetByEmail

func (r *CachedUserRepository) GetByEmail(ctx context.Context, email string) (*model.User, error)

func (*CachedUserRepository) Update

func (r *CachedUserRepository) Update(ctx context.Context, id model.ID, patch map[string]any) (*model.User, error)

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database represents a Redis database, wrapping a redis connection.

func NewDatabase

func NewDatabase(opts ...DatabaseOption) (*Database, error)

NewDatabase creates a new Redis database.

func (*Database) Close

func (db *Database) Close() error

Close closes the database connection.

func (*Database) GetClient

func (db *Database) GetClient() redis.UniversalClient

GetClient returns the database client.

func (*Database) Ping

func (db *Database) Ping(ctx context.Context) error

Ping checks the database connection.

type DatabaseOption

type DatabaseOption func(*Database) error

DatabaseOption configures a Redis database.

func WithClient

func WithClient(client redis.UniversalClient) DatabaseOption

WithClient sets the client for a Redis database.

func WithDatabaseLogger

func WithDatabaseLogger(logger log.Logger) DatabaseOption

WithDatabaseLogger sets the logger for a Neo4j database.

func WithDatabaseTracer

func WithDatabaseTracer(tracer tracing.Tracer) DatabaseOption

WithDatabaseTracer sets the tracer for a Neo4j database.

type RepositoryOption

type RepositoryOption func(*baseRepository) error

RepositoryOption configures a baseRepository for a Neo4j baseRepository.

func WithDatabase

func WithDatabase(db *Database) RepositoryOption

WithDatabase sets the baseRepository for a baseRepository.

func WithRepositoryLogger

func WithRepositoryLogger(logger log.Logger) RepositoryOption

WithRepositoryLogger sets the logger for a baseRepository.

func WithRepositoryTracer

func WithRepositoryTracer(tracer tracing.Tracer) RepositoryOption

WithRepositoryTracer sets the tracer for a baseRepository.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL