[performance] add user cache and database (#879)

* go fmt

* add + use user cache and database

* fix import

* update tests

* remove unused relation
This commit is contained in:
tobi 2022-10-03 10:46:11 +02:00 committed by GitHub
commit 56f53a2a6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 490 additions and 70 deletions

View file

@ -87,6 +87,7 @@ type DBService struct {
db.Session
db.Status
db.Timeline
db.User
conn *DBConn
}
@ -181,13 +182,15 @@ func NewBunDBService(ctx context.Context) (db.DB, error) {
notifCache.SetTTL(time.Minute*5, false)
notifCache.Start(time.Second * 10)
// Prepare domain block cache
// Prepare other caches
blockCache := cache.NewDomainBlockCache()
userCache := cache.NewUserCache()
ps := &DBService{
Account: accounts,
Admin: &adminDB{
conn: conn,
conn: conn,
userCache: userCache,
},
Basic: &basicDB{
conn: conn,
@ -219,7 +222,11 @@ func NewBunDBService(ctx context.Context) (db.DB, error) {
},
Status: status,
Timeline: timeline,
conn: conn,
User: &userDB{
conn: conn,
cache: userCache,
},
conn: conn,
}
// we can confidently return this useable service now