summaryrefslogtreecommitdiff
path: root/internal/db/bundb/bundb.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-09-02 11:17:46 +0100
committerLibravatar GitHub <noreply@github.com>2022-09-02 12:17:46 +0200
commitd68c04a6c0964d795a8d475c2f73d201bc72e68b (patch)
tree415746fa7279c4776ee822f1513f45c28a22e547 /internal/db/bundb/bundb.go
parent[feature] Federate custom emoji (outbound) (#791) (diff)
downloadgotosocial-d68c04a6c0964d795a8d475c2f73d201bc72e68b.tar.xz
[performance] cache recently allowed/denied domains to cut down on db calls (#794)
* fetch creation and fetching domain blocks from db Signed-off-by: kim <grufwub@gmail.com> * add separate domainblock cache type, handle removing block from cache on delete Signed-off-by: kim <grufwub@gmail.com> * fix sentinel nil values being passed into cache Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/db/bundb/bundb.go')
-rw-r--r--internal/db/bundb/bundb.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/db/bundb/bundb.go b/internal/db/bundb/bundb.go
index ca123543a..6bf3571b4 100644
--- a/internal/db/bundb/bundb.go
+++ b/internal/db/bundb/bundb.go
@@ -173,6 +173,9 @@ func NewBunDBService(ctx context.Context) (db.DB, error) {
notifCache.SetTTL(time.Minute*5, false)
notifCache.Start(time.Second * 10)
+ // Prepare domain block cache
+ blockCache := cache.NewDomainBlockCache()
+
ps := &bunDBService{
Account: accounts,
Admin: &adminDB{
@@ -182,7 +185,8 @@ func NewBunDBService(ctx context.Context) (db.DB, error) {
conn: conn,
},
Domain: &domainDB{
- conn: conn,
+ conn: conn,
+ cache: blockCache,
},
Emoji: &emojiDB{
conn: conn,