Doing some work

This commit is contained in:
2026-01-22 12:21:57 -06:00
parent 623bc860d4
commit a216f1ca5b
15 changed files with 1048 additions and 71 deletions

View File

@@ -21,9 +21,33 @@ THE SOFTWARE.
*/
package data
import (
"time"
"git.bullercodeworks.com/brian/expds/data/models"
)
type Repo struct {
LoadedPDSs map[string]*models.Pds
BestBy time.Duration
}
func NewRepo() (*Repo, error) {
return &Repo{}, nil
return &Repo{
LoadedPDSs: make(map[string]*models.Pds),
BestBy: time.Minute * 15,
}, nil
}
func (r *Repo) GetPDS(atId string) (*models.Pds, error) {
if p, ok := r.LoadedPDSs[atId]; ok && time.Since(p.RefreshTime) < r.BestBy {
return p, nil
}
p, err := models.NewPdsFromDid(atId)
if err != nil {
return nil, err
}
r.LoadedPDSs[atId] = p
return p, nil
}