Moved ledis implementation to a new package

This commit is contained in:
Deluan 2020-01-09 23:01:04 -05:00 committed by Deluan Quintão
parent a4a8360a94
commit 018352463f
19 changed files with 56 additions and 56 deletions

View file

@ -1,43 +0,0 @@
package persistence
import (
"errors"
"github.com/cloudsonic/sonic-server/domain"
)
type propertyRepository struct {
ledisRepository
}
func NewPropertyRepository() domain.PropertyRepository {
r := &propertyRepository{}
r.init("property", &domain.Property{})
return r
}
func (r *propertyRepository) Put(id string, value string) error {
m := &domain.Property{Id: id, Value: value}
if m.Id == "" {
return errors.New("Id is required")
}
return r.saveOrUpdate(m.Id, m)
}
func (r *propertyRepository) Get(id string) (string, error) {
var rec interface{}
rec, err := r.readEntity(id)
return rec.(*domain.Property).Value, err
}
func (r *propertyRepository) DefaultGet(id string, defaultValue string) (string, error) {
v, err := r.Get(id)
if err == domain.ErrNotFound {
return defaultValue, nil
}
return v, err
}
var _ domain.PropertyRepository = (*propertyRepository)(nil)