mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-28 04:23:32 -06:00
Add preview card storing to the database
This commit is contained in:
parent
85c32526f2
commit
6169351d22
12 changed files with 228 additions and 55 deletions
29
internal/cache/db.go
vendored
29
internal/cache/db.go
vendored
|
|
@ -52,6 +52,9 @@ type DBCaches struct {
|
|||
// BoostOfIDs provides access to the boost of IDs list database cache.
|
||||
BoostOfIDs SliceCache[string]
|
||||
|
||||
// Card provides access to the gtsmodel Card database cache.
|
||||
Card StructCache[*gtsmodel.Card]
|
||||
|
||||
// Conversation provides access to the gtsmodel Conversation database cache.
|
||||
Conversation StructCache[*gtsmodel.Conversation]
|
||||
|
||||
|
|
@ -637,6 +640,32 @@ func (c *Caches) initEmoji() {
|
|||
})
|
||||
}
|
||||
|
||||
func (c *Caches) initCard() {
|
||||
// Calculate maximum cache size.
|
||||
cap := calculateResultCacheMax(
|
||||
sizeofCard(), // model in-mem size.
|
||||
config.GetCacheEmojiMemRatio(), // TODO: this need to be replaced with GetCacheCardMemRatio
|
||||
)
|
||||
|
||||
log.Infof(nil, "cache size = %d", cap)
|
||||
|
||||
copyF := func(e1 *gtsmodel.Card) *gtsmodel.Card {
|
||||
e2 := new(gtsmodel.Card)
|
||||
*e2 = *e1
|
||||
|
||||
return e2
|
||||
}
|
||||
|
||||
c.DB.Card.Init(structr.CacheConfig[*gtsmodel.Card]{
|
||||
Indices: []structr.IndexConfig{
|
||||
{Fields: "ID"},
|
||||
},
|
||||
MaxSize: cap,
|
||||
IgnoreErr: ignoreErrors,
|
||||
Copy: copyF,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Caches) initEmojiCategory() {
|
||||
// Calculate maximum cache size.
|
||||
cap := calculateResultCacheMax(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue