2023-03-12 15:00:57 +00:00
|
|
|
// GoToSocial
|
|
|
|
// Copyright (C) GoToSocial Authors admin@gotosocial.org
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2022-12-08 17:35:14 +00:00
|
|
|
|
|
|
|
package cache
|
|
|
|
|
|
|
|
import (
|
2023-08-03 09:34:35 +00:00
|
|
|
"time"
|
|
|
|
|
2022-12-08 17:35:14 +00:00
|
|
|
"codeberg.org/gruf/go-cache/v3/result"
|
2023-08-03 09:34:35 +00:00
|
|
|
"codeberg.org/gruf/go-cache/v3/simple"
|
2023-03-08 12:57:41 +00:00
|
|
|
"codeberg.org/gruf/go-cache/v3/ttl"
|
2022-12-14 09:55:36 +00:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/cache/domain"
|
2022-12-11 13:03:15 +00:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/config"
|
2022-12-08 17:35:14 +00:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
2023-08-03 09:34:35 +00:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/log"
|
2022-12-08 17:35:14 +00:00
|
|
|
)
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
type GTSCaches struct {
|
2023-07-31 10:25:29 +00:00
|
|
|
account *result.Cache[*gtsmodel.Account]
|
|
|
|
accountNote *result.Cache[*gtsmodel.AccountNote]
|
2023-08-10 14:08:41 +00:00
|
|
|
application *result.Cache[*gtsmodel.Application]
|
2023-07-31 10:25:29 +00:00
|
|
|
block *result.Cache[*gtsmodel.Block]
|
|
|
|
blockIDs *SliceCache[string]
|
2023-08-04 11:28:33 +00:00
|
|
|
boostOfIDs *SliceCache[string]
|
2023-09-21 10:12:04 +00:00
|
|
|
domainAllow *domain.Cache
|
|
|
|
domainBlock *domain.Cache
|
2023-07-31 10:25:29 +00:00
|
|
|
emoji *result.Cache[*gtsmodel.Emoji]
|
|
|
|
emojiCategory *result.Cache[*gtsmodel.EmojiCategory]
|
|
|
|
follow *result.Cache[*gtsmodel.Follow]
|
|
|
|
followIDs *SliceCache[string]
|
|
|
|
followRequest *result.Cache[*gtsmodel.FollowRequest]
|
|
|
|
followRequestIDs *SliceCache[string]
|
|
|
|
instance *result.Cache[*gtsmodel.Instance]
|
2023-08-04 11:28:33 +00:00
|
|
|
inReplyToIDs *SliceCache[string]
|
2023-07-31 10:25:29 +00:00
|
|
|
list *result.Cache[*gtsmodel.List]
|
|
|
|
listEntry *result.Cache[*gtsmodel.ListEntry]
|
|
|
|
marker *result.Cache[*gtsmodel.Marker]
|
|
|
|
media *result.Cache[*gtsmodel.MediaAttachment]
|
|
|
|
mention *result.Cache[*gtsmodel.Mention]
|
|
|
|
notification *result.Cache[*gtsmodel.Notification]
|
2023-11-08 14:32:17 +00:00
|
|
|
poll *result.Cache[*gtsmodel.Poll]
|
|
|
|
pollVote *result.Cache[*gtsmodel.PollVote]
|
|
|
|
pollVoteIDs *SliceCache[string]
|
2023-07-31 10:25:29 +00:00
|
|
|
report *result.Cache[*gtsmodel.Report]
|
|
|
|
status *result.Cache[*gtsmodel.Status]
|
|
|
|
statusFave *result.Cache[*gtsmodel.StatusFave]
|
2023-08-04 11:28:33 +00:00
|
|
|
statusFaveIDs *SliceCache[string]
|
2023-07-31 13:47:35 +00:00
|
|
|
tag *result.Cache[*gtsmodel.Tag]
|
2023-10-25 14:04:53 +00:00
|
|
|
threadMute *result.Cache[*gtsmodel.ThreadMute]
|
2023-07-31 10:25:29 +00:00
|
|
|
tombstone *result.Cache[*gtsmodel.Tombstone]
|
|
|
|
user *result.Cache[*gtsmodel.User]
|
|
|
|
|
|
|
|
// TODO: move out of GTS caches since unrelated to DB.
|
2023-08-03 09:34:35 +00:00
|
|
|
webfinger *ttl.Cache[string, string] // TTL=24hr, sweep=5min
|
2022-12-08 17:35:14 +00:00
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// Init will initialize all the gtsmodel caches in this collection.
|
|
|
|
// NOTE: the cache MUST NOT be in use anywhere, this is not thread-safe.
|
|
|
|
func (c *GTSCaches) Init() {
|
2022-12-08 17:35:14 +00:00
|
|
|
c.initAccount()
|
2023-07-27 08:30:39 +00:00
|
|
|
c.initAccountNote()
|
2023-08-10 14:08:41 +00:00
|
|
|
c.initApplication()
|
2022-12-08 17:35:14 +00:00
|
|
|
c.initBlock()
|
2023-07-31 10:25:29 +00:00
|
|
|
c.initBlockIDs()
|
2023-08-04 11:28:33 +00:00
|
|
|
c.initBoostOfIDs()
|
2023-09-21 10:12:04 +00:00
|
|
|
c.initDomainAllow()
|
2022-12-08 17:35:14 +00:00
|
|
|
c.initDomainBlock()
|
|
|
|
c.initEmoji()
|
|
|
|
c.initEmojiCategory()
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.initFollow()
|
2023-07-31 10:25:29 +00:00
|
|
|
c.initFollowIDs()
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.initFollowRequest()
|
2023-07-31 10:25:29 +00:00
|
|
|
c.initFollowRequestIDs()
|
2023-08-04 11:28:33 +00:00
|
|
|
c.initInReplyToIDs()
|
2023-07-07 09:34:12 +00:00
|
|
|
c.initInstance()
|
2023-05-25 08:37:38 +00:00
|
|
|
c.initList()
|
|
|
|
c.initListEntry()
|
2023-07-29 10:49:14 +00:00
|
|
|
c.initMarker()
|
2023-03-03 23:02:23 +00:00
|
|
|
c.initMedia()
|
2022-12-08 17:35:14 +00:00
|
|
|
c.initMention()
|
|
|
|
c.initNotification()
|
2023-11-08 14:32:17 +00:00
|
|
|
c.initPoll()
|
|
|
|
c.initPollVote()
|
|
|
|
c.initPollVoteIDs()
|
2023-01-10 14:19:05 +00:00
|
|
|
c.initReport()
|
2022-12-08 17:35:14 +00:00
|
|
|
c.initStatus()
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.initStatusFave()
|
2023-07-31 13:47:35 +00:00
|
|
|
c.initTag()
|
2023-10-25 14:04:53 +00:00
|
|
|
c.initThreadMute()
|
2023-08-04 11:28:33 +00:00
|
|
|
c.initStatusFaveIDs()
|
2022-12-08 17:35:14 +00:00
|
|
|
c.initTombstone()
|
|
|
|
c.initUser()
|
2023-03-08 12:57:41 +00:00
|
|
|
c.initWebfinger()
|
2022-12-08 17:35:14 +00:00
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// Start will attempt to start all of the gtsmodel caches, or panic.
|
|
|
|
func (c *GTSCaches) Start() {
|
|
|
|
tryUntil("starting *gtsmodel.Webfinger cache", 5, func() bool {
|
2023-08-03 09:34:35 +00:00
|
|
|
return c.webfinger.Start(5 * time.Minute)
|
2023-03-08 12:57:41 +00:00
|
|
|
})
|
2022-12-08 17:35:14 +00:00
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// Stop will attempt to stop all of the gtsmodel caches, or panic.
|
|
|
|
func (c *GTSCaches) Stop() {
|
2023-08-03 09:34:35 +00:00
|
|
|
tryUntil("stopping *gtsmodel.Webfinger cache", 5, c.webfinger.Stop)
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Account provides access to the gtsmodel Account database cache.
|
|
|
|
func (c *GTSCaches) Account() *result.Cache[*gtsmodel.Account] {
|
2022-12-08 17:35:14 +00:00
|
|
|
return c.account
|
|
|
|
}
|
|
|
|
|
2023-07-27 08:30:39 +00:00
|
|
|
// AccountNote provides access to the gtsmodel Note database cache.
|
|
|
|
func (c *GTSCaches) AccountNote() *result.Cache[*gtsmodel.AccountNote] {
|
|
|
|
return c.accountNote
|
|
|
|
}
|
|
|
|
|
2023-08-10 14:08:41 +00:00
|
|
|
// Application provides access to the gtsmodel Application database cache.
|
|
|
|
func (c *GTSCaches) Application() *result.Cache[*gtsmodel.Application] {
|
|
|
|
return c.application
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// Block provides access to the gtsmodel Block (account) database cache.
|
|
|
|
func (c *GTSCaches) Block() *result.Cache[*gtsmodel.Block] {
|
2022-12-08 17:35:14 +00:00
|
|
|
return c.block
|
|
|
|
}
|
|
|
|
|
2023-07-31 10:25:29 +00:00
|
|
|
// FollowIDs provides access to the block IDs database cache.
|
|
|
|
func (c *GTSCaches) BlockIDs() *SliceCache[string] {
|
|
|
|
return c.blockIDs
|
|
|
|
}
|
|
|
|
|
2023-08-04 11:28:33 +00:00
|
|
|
// BoostOfIDs provides access to the boost of IDs list database cache.
|
|
|
|
func (c *GTSCaches) BoostOfIDs() *SliceCache[string] {
|
|
|
|
return c.boostOfIDs
|
|
|
|
}
|
|
|
|
|
2023-09-21 10:12:04 +00:00
|
|
|
// DomainAllow provides access to the domain allow database cache.
|
|
|
|
func (c *GTSCaches) DomainAllow() *domain.Cache {
|
|
|
|
return c.domainAllow
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// DomainBlock provides access to the domain block database cache.
|
2023-09-21 10:12:04 +00:00
|
|
|
func (c *GTSCaches) DomainBlock() *domain.Cache {
|
2022-12-08 17:35:14 +00:00
|
|
|
return c.domainBlock
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// Emoji provides access to the gtsmodel Emoji database cache.
|
|
|
|
func (c *GTSCaches) Emoji() *result.Cache[*gtsmodel.Emoji] {
|
2022-12-08 17:35:14 +00:00
|
|
|
return c.emoji
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// EmojiCategory provides access to the gtsmodel EmojiCategory database cache.
|
|
|
|
func (c *GTSCaches) EmojiCategory() *result.Cache[*gtsmodel.EmojiCategory] {
|
2022-12-08 17:35:14 +00:00
|
|
|
return c.emojiCategory
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// Follow provides access to the gtsmodel Follow database cache.
|
|
|
|
func (c *GTSCaches) Follow() *result.Cache[*gtsmodel.Follow] {
|
|
|
|
return c.follow
|
|
|
|
}
|
|
|
|
|
2023-07-31 10:25:29 +00:00
|
|
|
// FollowIDs provides access to the follower / following IDs database cache.
|
|
|
|
// THIS CACHE IS KEYED AS THE FOLLOWING {prefix}{accountID} WHERE PREFIX IS:
|
|
|
|
// - '>' for following IDs
|
|
|
|
// - 'l>' for local following IDs
|
|
|
|
// - '<' for follower IDs
|
|
|
|
// - 'l<' for local follower IDs
|
|
|
|
func (c *GTSCaches) FollowIDs() *SliceCache[string] {
|
|
|
|
return c.followIDs
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// FollowRequest provides access to the gtsmodel FollowRequest database cache.
|
|
|
|
func (c *GTSCaches) FollowRequest() *result.Cache[*gtsmodel.FollowRequest] {
|
|
|
|
return c.followRequest
|
|
|
|
}
|
|
|
|
|
2023-07-31 10:25:29 +00:00
|
|
|
// FollowRequestIDs provides access to the follow requester / requesting IDs database
|
|
|
|
// cache. THIS CACHE IS KEYED AS THE FOLLOWING {prefix}{accountID} WHERE PREFIX IS:
|
|
|
|
// - '>' for following IDs
|
|
|
|
// - '<' for follower IDs
|
|
|
|
func (c *GTSCaches) FollowRequestIDs() *SliceCache[string] {
|
|
|
|
return c.followRequestIDs
|
|
|
|
}
|
|
|
|
|
2023-07-07 09:34:12 +00:00
|
|
|
// Instance provides access to the gtsmodel Instance database cache.
|
|
|
|
func (c *GTSCaches) Instance() *result.Cache[*gtsmodel.Instance] {
|
|
|
|
return c.instance
|
|
|
|
}
|
|
|
|
|
2023-08-04 11:28:33 +00:00
|
|
|
// InReplyToIDs provides access to the status in reply to IDs list database cache.
|
|
|
|
func (c *GTSCaches) InReplyToIDs() *SliceCache[string] {
|
|
|
|
return c.inReplyToIDs
|
|
|
|
}
|
|
|
|
|
2023-05-25 08:37:38 +00:00
|
|
|
// List provides access to the gtsmodel List database cache.
|
|
|
|
func (c *GTSCaches) List() *result.Cache[*gtsmodel.List] {
|
|
|
|
return c.list
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListEntry provides access to the gtsmodel ListEntry database cache.
|
|
|
|
func (c *GTSCaches) ListEntry() *result.Cache[*gtsmodel.ListEntry] {
|
|
|
|
return c.listEntry
|
|
|
|
}
|
|
|
|
|
2023-07-29 10:49:14 +00:00
|
|
|
// Marker provides access to the gtsmodel Marker database cache.
|
|
|
|
func (c *GTSCaches) Marker() *result.Cache[*gtsmodel.Marker] {
|
|
|
|
return c.marker
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// Media provides access to the gtsmodel Media database cache.
|
|
|
|
func (c *GTSCaches) Media() *result.Cache[*gtsmodel.MediaAttachment] {
|
2023-03-03 23:02:23 +00:00
|
|
|
return c.media
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// Mention provides access to the gtsmodel Mention database cache.
|
|
|
|
func (c *GTSCaches) Mention() *result.Cache[*gtsmodel.Mention] {
|
2022-12-08 17:35:14 +00:00
|
|
|
return c.mention
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// Notification provides access to the gtsmodel Notification database cache.
|
|
|
|
func (c *GTSCaches) Notification() *result.Cache[*gtsmodel.Notification] {
|
2022-12-08 17:35:14 +00:00
|
|
|
return c.notification
|
|
|
|
}
|
|
|
|
|
2023-11-08 14:32:17 +00:00
|
|
|
// Poll provides access to the gtsmodel Poll database cache.
|
|
|
|
func (c *GTSCaches) Poll() *result.Cache[*gtsmodel.Poll] {
|
|
|
|
return c.poll
|
|
|
|
}
|
|
|
|
|
|
|
|
// PollVote provides access to the gtsmodel PollVote database cache.
|
|
|
|
func (c *GTSCaches) PollVote() *result.Cache[*gtsmodel.PollVote] {
|
|
|
|
return c.pollVote
|
|
|
|
}
|
|
|
|
|
|
|
|
// PollVoteIDs provides access to the poll vote IDs list database cache.
|
|
|
|
func (c *GTSCaches) PollVoteIDs() *SliceCache[string] {
|
|
|
|
return c.pollVoteIDs
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// Report provides access to the gtsmodel Report database cache.
|
|
|
|
func (c *GTSCaches) Report() *result.Cache[*gtsmodel.Report] {
|
2023-01-10 14:19:05 +00:00
|
|
|
return c.report
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// Status provides access to the gtsmodel Status database cache.
|
|
|
|
func (c *GTSCaches) Status() *result.Cache[*gtsmodel.Status] {
|
2022-12-08 17:35:14 +00:00
|
|
|
return c.status
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// StatusFave provides access to the gtsmodel StatusFave database cache.
|
|
|
|
func (c *GTSCaches) StatusFave() *result.Cache[*gtsmodel.StatusFave] {
|
|
|
|
return c.statusFave
|
|
|
|
}
|
|
|
|
|
2023-08-04 11:28:33 +00:00
|
|
|
// StatusFaveIDs provides access to the status fave IDs list database cache.
|
|
|
|
func (c *GTSCaches) StatusFaveIDs() *SliceCache[string] {
|
|
|
|
return c.statusFaveIDs
|
|
|
|
}
|
|
|
|
|
2023-11-08 14:32:17 +00:00
|
|
|
// Tag provides access to the gtsmodel Tag database cache.
|
|
|
|
func (c *GTSCaches) Tag() *result.Cache[*gtsmodel.Tag] {
|
|
|
|
return c.tag
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// Tombstone provides access to the gtsmodel Tombstone database cache.
|
|
|
|
func (c *GTSCaches) Tombstone() *result.Cache[*gtsmodel.Tombstone] {
|
2022-12-08 17:35:14 +00:00
|
|
|
return c.tombstone
|
|
|
|
}
|
|
|
|
|
2023-11-08 14:32:17 +00:00
|
|
|
// ThreadMute provides access to the gtsmodel ThreadMute database cache.
|
|
|
|
func (c *GTSCaches) ThreadMute() *result.Cache[*gtsmodel.ThreadMute] {
|
|
|
|
return c.threadMute
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// User provides access to the gtsmodel User database cache.
|
|
|
|
func (c *GTSCaches) User() *result.Cache[*gtsmodel.User] {
|
2022-12-08 17:35:14 +00:00
|
|
|
return c.user
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
// Webfinger provides access to the webfinger URL cache.
|
|
|
|
func (c *GTSCaches) Webfinger() *ttl.Cache[string, string] {
|
2023-03-08 12:57:41 +00:00
|
|
|
return c.webfinger
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initAccount() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofAccount(), // model in-mem size.
|
|
|
|
config.GetCacheAccountMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(a1 *gtsmodel.Account) *gtsmodel.Account {
|
|
|
|
a2 := new(gtsmodel.Account)
|
|
|
|
*a2 = *a1
|
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/account.go.
|
|
|
|
a2.AvatarMediaAttachment = nil
|
|
|
|
a2.HeaderMediaAttachment = nil
|
|
|
|
a2.Emojis = nil
|
|
|
|
|
|
|
|
return a2
|
|
|
|
}
|
|
|
|
|
2022-12-16 22:36:52 +00:00
|
|
|
c.account = result.New([]result.Lookup{
|
2022-12-08 17:35:14 +00:00
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "URI"},
|
|
|
|
{Name: "URL"},
|
2023-08-04 11:28:33 +00:00
|
|
|
{Name: "Username.Domain", AllowZero: true /* domain can be zero i.e. "" */},
|
2022-12-08 17:35:14 +00:00
|
|
|
{Name: "PublicKeyURI"},
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
{Name: "InboxURI"},
|
|
|
|
{Name: "OutboxURI"},
|
|
|
|
{Name: "FollowersURI"},
|
|
|
|
{Name: "FollowingURI"},
|
2023-11-27 15:39:44 +00:00
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.account.IgnoreErrors(ignoreErrors)
|
2022-12-08 17:35:14 +00:00
|
|
|
}
|
|
|
|
|
2023-07-27 08:30:39 +00:00
|
|
|
func (c *GTSCaches) initAccountNote() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofAccountNote(), // model in-mem size.
|
|
|
|
config.GetCacheAccountNoteMemRatio(),
|
|
|
|
)
|
2023-08-14 16:08:19 +00:00
|
|
|
|
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(n1 *gtsmodel.AccountNote) *gtsmodel.AccountNote {
|
2023-07-27 08:30:39 +00:00
|
|
|
n2 := new(gtsmodel.AccountNote)
|
|
|
|
*n2 = *n1
|
2023-11-27 15:39:44 +00:00
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/relationship_note.go.
|
|
|
|
n2.Account = nil
|
|
|
|
n2.TargetAccount = nil
|
|
|
|
|
2023-07-27 08:30:39 +00:00
|
|
|
return n2
|
2023-11-27 15:39:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c.accountNote = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "AccountID.TargetAccountID"},
|
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-07-27 08:30:39 +00:00
|
|
|
c.accountNote.IgnoreErrors(ignoreErrors)
|
|
|
|
}
|
|
|
|
|
2023-08-10 14:08:41 +00:00
|
|
|
func (c *GTSCaches) initApplication() {
|
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofApplication(), // model in-mem size.
|
|
|
|
config.GetCacheApplicationMemRatio(),
|
|
|
|
)
|
2023-08-14 16:08:19 +00:00
|
|
|
|
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-10 14:08:41 +00:00
|
|
|
|
|
|
|
c.application = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "ClientID"},
|
|
|
|
}, func(a1 *gtsmodel.Application) *gtsmodel.Application {
|
|
|
|
a2 := new(gtsmodel.Application)
|
|
|
|
*a2 = *a1
|
|
|
|
return a2
|
|
|
|
}, cap)
|
|
|
|
|
|
|
|
c.application.IgnoreErrors(ignoreErrors)
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initBlock() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofBlock(), // model in-mem size.
|
|
|
|
config.GetCacheBlockMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(b1 *gtsmodel.Block) *gtsmodel.Block {
|
|
|
|
b2 := new(gtsmodel.Block)
|
|
|
|
*b2 = *b1
|
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/relationship_block.go.
|
|
|
|
b2.Account = nil
|
|
|
|
b2.TargetAccount = nil
|
|
|
|
|
|
|
|
return b2
|
|
|
|
}
|
|
|
|
|
2022-12-16 22:36:52 +00:00
|
|
|
c.block = result.New([]result.Lookup{
|
2022-12-08 17:35:14 +00:00
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "URI"},
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
{Name: "AccountID.TargetAccountID"},
|
2023-07-31 10:25:29 +00:00
|
|
|
{Name: "AccountID", Multi: true},
|
|
|
|
{Name: "TargetAccountID", Multi: true},
|
2023-11-27 15:39:44 +00:00
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.block.IgnoreErrors(ignoreErrors)
|
2022-12-08 17:35:14 +00:00
|
|
|
}
|
|
|
|
|
2023-07-31 10:25:29 +00:00
|
|
|
func (c *GTSCaches) initBlockIDs() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateSliceCacheMax(
|
|
|
|
config.GetCacheBlockIDsMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
|
|
|
c.blockIDs = &SliceCache[string]{Cache: simple.New[string, []string](
|
2023-07-31 10:25:29 +00:00
|
|
|
0,
|
2023-08-03 09:34:35 +00:00
|
|
|
cap,
|
2023-07-31 10:25:29 +00:00
|
|
|
)}
|
|
|
|
}
|
|
|
|
|
2023-08-04 11:28:33 +00:00
|
|
|
func (c *GTSCaches) initBoostOfIDs() {
|
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateSliceCacheMax(
|
|
|
|
config.GetCacheBoostOfIDsMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-04 11:28:33 +00:00
|
|
|
|
|
|
|
c.boostOfIDs = &SliceCache[string]{Cache: simple.New[string, []string](
|
|
|
|
0,
|
|
|
|
cap,
|
|
|
|
)}
|
|
|
|
}
|
|
|
|
|
2023-09-21 10:12:04 +00:00
|
|
|
func (c *GTSCaches) initDomainAllow() {
|
|
|
|
c.domainAllow = new(domain.Cache)
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initDomainBlock() {
|
2023-09-21 10:12:04 +00:00
|
|
|
c.domainBlock = new(domain.Cache)
|
2022-12-08 17:35:14 +00:00
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initEmoji() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofEmoji(), // model in-mem size.
|
|
|
|
config.GetCacheEmojiMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(e1 *gtsmodel.Emoji) *gtsmodel.Emoji {
|
|
|
|
e2 := new(gtsmodel.Emoji)
|
|
|
|
*e2 = *e1
|
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/emoji.go.
|
|
|
|
e2.Category = nil
|
|
|
|
|
|
|
|
return e2
|
|
|
|
}
|
|
|
|
|
2022-12-16 22:36:52 +00:00
|
|
|
c.emoji = result.New([]result.Lookup{
|
2022-12-08 17:35:14 +00:00
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "URI"},
|
2023-08-04 11:28:33 +00:00
|
|
|
{Name: "Shortcode.Domain", AllowZero: true /* domain can be zero i.e. "" */},
|
2022-12-08 17:35:14 +00:00
|
|
|
{Name: "ImageStaticURL"},
|
2023-07-18 08:43:17 +00:00
|
|
|
{Name: "CategoryID", Multi: true},
|
2023-11-27 15:39:44 +00:00
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.emoji.IgnoreErrors(ignoreErrors)
|
2022-12-08 17:35:14 +00:00
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initEmojiCategory() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofEmojiCategory(), // model in-mem size.
|
|
|
|
config.GetCacheEmojiCategoryMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2022-12-16 22:36:52 +00:00
|
|
|
c.emojiCategory = result.New([]result.Lookup{
|
2022-12-08 17:35:14 +00:00
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "Name"},
|
|
|
|
}, func(c1 *gtsmodel.EmojiCategory) *gtsmodel.EmojiCategory {
|
|
|
|
c2 := new(gtsmodel.EmojiCategory)
|
|
|
|
*c2 = *c1
|
|
|
|
return c2
|
2023-08-03 09:34:35 +00:00
|
|
|
}, cap)
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.emojiCategory.IgnoreErrors(ignoreErrors)
|
2022-12-08 17:35:14 +00:00
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initFollow() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofFollow(), // model in-mem size.
|
|
|
|
config.GetCacheFollowMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(f1 *gtsmodel.Follow) *gtsmodel.Follow {
|
|
|
|
f2 := new(gtsmodel.Follow)
|
|
|
|
*f2 = *f1
|
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/relationship_follow.go.
|
|
|
|
f2.Account = nil
|
|
|
|
f2.TargetAccount = nil
|
|
|
|
|
|
|
|
return f2
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.follow = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "URI"},
|
|
|
|
{Name: "AccountID.TargetAccountID"},
|
2023-07-31 10:25:29 +00:00
|
|
|
{Name: "AccountID", Multi: true},
|
|
|
|
{Name: "TargetAccountID", Multi: true},
|
2023-11-27 15:39:44 +00:00
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
|
|
|
c.follow.IgnoreErrors(ignoreErrors)
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
}
|
|
|
|
|
2023-07-31 10:25:29 +00:00
|
|
|
func (c *GTSCaches) initFollowIDs() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateSliceCacheMax(
|
|
|
|
config.GetCacheFollowIDsMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
|
|
|
c.followIDs = &SliceCache[string]{Cache: simple.New[string, []string](
|
2023-07-31 10:25:29 +00:00
|
|
|
0,
|
2023-08-03 09:34:35 +00:00
|
|
|
cap,
|
2023-07-31 10:25:29 +00:00
|
|
|
)}
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initFollowRequest() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofFollowRequest(), // model in-mem size.
|
|
|
|
config.GetCacheFollowRequestMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(f1 *gtsmodel.FollowRequest) *gtsmodel.FollowRequest {
|
|
|
|
f2 := new(gtsmodel.FollowRequest)
|
|
|
|
*f2 = *f1
|
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/relationship_follow_req.go.
|
|
|
|
f2.Account = nil
|
|
|
|
f2.TargetAccount = nil
|
|
|
|
|
|
|
|
return f2
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.followRequest = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "URI"},
|
|
|
|
{Name: "AccountID.TargetAccountID"},
|
2023-07-31 10:25:29 +00:00
|
|
|
{Name: "AccountID", Multi: true},
|
|
|
|
{Name: "TargetAccountID", Multi: true},
|
2023-11-27 15:39:44 +00:00
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
|
|
|
c.followRequest.IgnoreErrors(ignoreErrors)
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
}
|
|
|
|
|
2023-07-31 10:25:29 +00:00
|
|
|
func (c *GTSCaches) initFollowRequestIDs() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateSliceCacheMax(
|
|
|
|
config.GetCacheFollowRequestIDsMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
|
|
|
c.followRequestIDs = &SliceCache[string]{Cache: simple.New[string, []string](
|
2023-07-31 10:25:29 +00:00
|
|
|
0,
|
2023-08-03 09:34:35 +00:00
|
|
|
cap,
|
2023-07-31 10:25:29 +00:00
|
|
|
)}
|
|
|
|
}
|
|
|
|
|
2023-08-04 11:28:33 +00:00
|
|
|
func (c *GTSCaches) initInReplyToIDs() {
|
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateSliceCacheMax(
|
|
|
|
config.GetCacheInReplyToIDsMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-04 11:28:33 +00:00
|
|
|
|
|
|
|
c.inReplyToIDs = &SliceCache[string]{Cache: simple.New[string, []string](
|
|
|
|
0,
|
|
|
|
cap,
|
|
|
|
)}
|
|
|
|
}
|
|
|
|
|
2023-07-07 09:34:12 +00:00
|
|
|
func (c *GTSCaches) initInstance() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofInstance(), // model in-mem size.
|
|
|
|
config.GetCacheInstanceMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(i1 *gtsmodel.Instance) *gtsmodel.Instance {
|
2023-07-07 09:34:12 +00:00
|
|
|
i2 := new(gtsmodel.Instance)
|
|
|
|
*i2 = *i1
|
2023-11-27 15:39:44 +00:00
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/instance.go.
|
|
|
|
i2.DomainBlock = nil
|
|
|
|
i2.ContactAccount = nil
|
|
|
|
|
2023-07-07 09:34:12 +00:00
|
|
|
return i1
|
2023-11-27 15:39:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c.instance = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "Domain"},
|
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
|
|
|
c.instance.IgnoreErrors(ignoreErrors)
|
2023-07-07 09:34:12 +00:00
|
|
|
}
|
|
|
|
|
2023-05-25 08:37:38 +00:00
|
|
|
func (c *GTSCaches) initList() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofList(), // model in-mem size.
|
|
|
|
config.GetCacheListMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(l1 *gtsmodel.List) *gtsmodel.List {
|
2023-05-25 08:37:38 +00:00
|
|
|
l2 := new(gtsmodel.List)
|
|
|
|
*l2 = *l1
|
2023-11-27 15:39:44 +00:00
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/list.go.
|
|
|
|
l2.Account = nil
|
|
|
|
l2.ListEntries = nil
|
|
|
|
|
2023-05-25 08:37:38 +00:00
|
|
|
return l2
|
2023-11-27 15:39:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c.list = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-05-25 08:37:38 +00:00
|
|
|
c.list.IgnoreErrors(ignoreErrors)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *GTSCaches) initListEntry() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofListEntry(), // model in-mem size.
|
|
|
|
config.GetCacheListEntryMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(l1 *gtsmodel.ListEntry) *gtsmodel.ListEntry {
|
|
|
|
l2 := new(gtsmodel.ListEntry)
|
|
|
|
*l2 = *l1
|
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/list.go.
|
|
|
|
l2.Follow = nil
|
|
|
|
|
|
|
|
return l2
|
|
|
|
}
|
|
|
|
|
2023-05-25 08:37:38 +00:00
|
|
|
c.listEntry = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
2023-07-18 08:43:17 +00:00
|
|
|
{Name: "ListID", Multi: true},
|
|
|
|
{Name: "FollowID", Multi: true},
|
2023-11-27 15:39:44 +00:00
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
|
|
|
c.listEntry.IgnoreErrors(ignoreErrors)
|
2023-05-25 08:37:38 +00:00
|
|
|
}
|
|
|
|
|
2023-07-29 10:49:14 +00:00
|
|
|
func (c *GTSCaches) initMarker() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofMarker(), // model in-mem size.
|
|
|
|
config.GetCacheMarkerMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-07-29 10:49:14 +00:00
|
|
|
c.marker = result.New([]result.Lookup{
|
|
|
|
{Name: "AccountID.Name"},
|
|
|
|
}, func(m1 *gtsmodel.Marker) *gtsmodel.Marker {
|
|
|
|
m2 := new(gtsmodel.Marker)
|
|
|
|
*m2 = *m1
|
|
|
|
return m2
|
2023-08-03 09:34:35 +00:00
|
|
|
}, cap)
|
|
|
|
|
2023-07-29 10:49:14 +00:00
|
|
|
c.marker.IgnoreErrors(ignoreErrors)
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initMedia() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofMedia(), // model in-mem size.
|
|
|
|
config.GetCacheMediaMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-03-03 23:02:23 +00:00
|
|
|
c.media = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
}, func(m1 *gtsmodel.MediaAttachment) *gtsmodel.MediaAttachment {
|
|
|
|
m2 := new(gtsmodel.MediaAttachment)
|
|
|
|
*m2 = *m1
|
|
|
|
return m2
|
2023-08-03 09:34:35 +00:00
|
|
|
}, cap)
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.media.IgnoreErrors(ignoreErrors)
|
2023-03-03 23:02:23 +00:00
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initMention() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofMention(), // model in-mem size.
|
|
|
|
config.GetCacheMentionMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(m1 *gtsmodel.Mention) *gtsmodel.Mention {
|
2022-12-08 17:35:14 +00:00
|
|
|
m2 := new(gtsmodel.Mention)
|
|
|
|
*m2 = *m1
|
2023-11-27 15:39:44 +00:00
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/mention.go.
|
|
|
|
m2.Status = nil
|
|
|
|
m2.OriginAccount = nil
|
|
|
|
m2.TargetAccount = nil
|
|
|
|
|
2022-12-08 17:35:14 +00:00
|
|
|
return m2
|
2023-11-27 15:39:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c.mention = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.mention.IgnoreErrors(ignoreErrors)
|
2022-12-08 17:35:14 +00:00
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initNotification() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofNotification(), // model in-mem size.
|
|
|
|
config.GetCacheNotificationMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(n1 *gtsmodel.Notification) *gtsmodel.Notification {
|
2022-12-08 17:35:14 +00:00
|
|
|
n2 := new(gtsmodel.Notification)
|
|
|
|
*n2 = *n1
|
2023-11-27 15:39:44 +00:00
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/notification.go.
|
|
|
|
n2.Status = nil
|
|
|
|
n2.OriginAccount = nil
|
|
|
|
n2.TargetAccount = nil
|
|
|
|
|
2022-12-08 17:35:14 +00:00
|
|
|
return n2
|
2023-11-27 15:39:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c.notification = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "NotificationType.TargetAccountID.OriginAccountID.StatusID"},
|
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.notification.IgnoreErrors(ignoreErrors)
|
2022-12-08 17:35:14 +00:00
|
|
|
}
|
|
|
|
|
2023-11-08 14:32:17 +00:00
|
|
|
func (c *GTSCaches) initPoll() {
|
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofPoll(), // model in-mem size.
|
|
|
|
config.GetCachePollMemRatio(),
|
|
|
|
)
|
|
|
|
|
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(p1 *gtsmodel.Poll) *gtsmodel.Poll {
|
2023-11-08 14:32:17 +00:00
|
|
|
p2 := new(gtsmodel.Poll)
|
|
|
|
*p2 = *p1
|
2023-11-27 15:39:44 +00:00
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/poll.go.
|
|
|
|
p2.Status = nil
|
|
|
|
|
2023-12-11 12:05:54 +00:00
|
|
|
// Don't include ephemeral fields
|
|
|
|
// which are only expected to be
|
|
|
|
// set on ONE poll instance.
|
|
|
|
p2.Closing = false
|
|
|
|
|
2023-11-08 14:32:17 +00:00
|
|
|
return p2
|
2023-11-27 15:39:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c.poll = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "StatusID"},
|
|
|
|
}, copyF, cap)
|
2023-11-08 14:32:17 +00:00
|
|
|
|
|
|
|
c.poll.IgnoreErrors(ignoreErrors)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *GTSCaches) initPollVote() {
|
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofPollVote(), // model in-mem size.
|
|
|
|
config.GetCachePollVoteMemRatio(),
|
|
|
|
)
|
|
|
|
|
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(v1 *gtsmodel.PollVote) *gtsmodel.PollVote {
|
|
|
|
v2 := new(gtsmodel.PollVote)
|
|
|
|
*v2 = *v1
|
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/poll.go.
|
|
|
|
v2.Account = nil
|
|
|
|
v2.Poll = nil
|
|
|
|
|
|
|
|
return v2
|
|
|
|
}
|
|
|
|
|
2023-11-08 14:32:17 +00:00
|
|
|
c.pollVote = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "PollID.AccountID"},
|
|
|
|
{Name: "PollID", Multi: true},
|
2023-11-27 15:39:44 +00:00
|
|
|
}, copyF, cap)
|
2023-11-08 14:32:17 +00:00
|
|
|
|
|
|
|
c.pollVote.IgnoreErrors(ignoreErrors)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *GTSCaches) initPollVoteIDs() {
|
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateSliceCacheMax(
|
|
|
|
config.GetCachePollVoteIDsMemRatio(),
|
|
|
|
)
|
|
|
|
|
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
|
|
|
|
|
|
|
c.pollVoteIDs = &SliceCache[string]{Cache: simple.New[string, []string](
|
|
|
|
0,
|
|
|
|
cap,
|
|
|
|
)}
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initReport() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofReport(), // model in-mem size.
|
|
|
|
config.GetCacheReportMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(r1 *gtsmodel.Report) *gtsmodel.Report {
|
2023-01-10 14:19:05 +00:00
|
|
|
r2 := new(gtsmodel.Report)
|
|
|
|
*r2 = *r1
|
2023-11-27 15:39:44 +00:00
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/report.go.
|
|
|
|
r2.Account = nil
|
|
|
|
r2.TargetAccount = nil
|
|
|
|
r2.Statuses = nil
|
|
|
|
r2.Rules = nil
|
|
|
|
r2.ActionTakenByAccount = nil
|
|
|
|
|
2023-01-10 14:19:05 +00:00
|
|
|
return r2
|
2023-11-27 15:39:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c.report = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.report.IgnoreErrors(ignoreErrors)
|
2023-01-10 14:19:05 +00:00
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initStatus() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofStatus(), // model in-mem size.
|
|
|
|
config.GetCacheStatusMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(s1 *gtsmodel.Status) *gtsmodel.Status {
|
|
|
|
s2 := new(gtsmodel.Status)
|
|
|
|
*s2 = *s1
|
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/status.go.
|
|
|
|
s2.Account = nil
|
|
|
|
s2.InReplyTo = nil
|
|
|
|
s2.InReplyToAccount = nil
|
|
|
|
s2.BoostOf = nil
|
|
|
|
s2.BoostOfAccount = nil
|
|
|
|
s2.Poll = nil
|
|
|
|
s2.Attachments = nil
|
|
|
|
s2.Tags = nil
|
|
|
|
s2.Mentions = nil
|
|
|
|
s2.Emojis = nil
|
|
|
|
s2.CreatedWithApplication = nil
|
|
|
|
|
|
|
|
return s2
|
|
|
|
}
|
|
|
|
|
2022-12-16 22:36:52 +00:00
|
|
|
c.status = result.New([]result.Lookup{
|
2022-12-08 17:35:14 +00:00
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "URI"},
|
|
|
|
{Name: "URL"},
|
2023-12-15 14:24:39 +00:00
|
|
|
{Name: "PollID"},
|
2023-08-04 11:28:33 +00:00
|
|
|
{Name: "BoostOfID.AccountID"},
|
2023-10-25 14:04:53 +00:00
|
|
|
{Name: "ThreadID", Multi: true},
|
2023-11-27 15:39:44 +00:00
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.status.IgnoreErrors(ignoreErrors)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *GTSCaches) initStatusFave() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofStatusFave(), // model in-mem size.
|
|
|
|
config.GetCacheStatusFaveMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(f1 *gtsmodel.StatusFave) *gtsmodel.StatusFave {
|
|
|
|
f2 := new(gtsmodel.StatusFave)
|
|
|
|
*f2 = *f1
|
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/statusfave.go.
|
|
|
|
f2.Account = nil
|
|
|
|
f2.TargetAccount = nil
|
|
|
|
f2.Status = nil
|
|
|
|
|
|
|
|
return f2
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.statusFave = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "AccountID.StatusID"},
|
2023-08-04 11:28:33 +00:00
|
|
|
{Name: "StatusID", Multi: true},
|
2023-11-27 15:39:44 +00:00
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
|
|
|
c.statusFave.IgnoreErrors(ignoreErrors)
|
2022-12-08 17:35:14 +00:00
|
|
|
}
|
|
|
|
|
2023-08-04 11:28:33 +00:00
|
|
|
func (c *GTSCaches) initStatusFaveIDs() {
|
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateSliceCacheMax(
|
|
|
|
config.GetCacheStatusFaveIDsMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-04 11:28:33 +00:00
|
|
|
|
|
|
|
c.statusFaveIDs = &SliceCache[string]{Cache: simple.New[string, []string](
|
|
|
|
0,
|
|
|
|
cap,
|
|
|
|
)}
|
|
|
|
}
|
|
|
|
|
2023-07-31 13:47:35 +00:00
|
|
|
func (c *GTSCaches) initTag() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofTag(), // model in-mem size.
|
|
|
|
config.GetCacheTagMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-07-31 13:47:35 +00:00
|
|
|
c.tag = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "Name"},
|
|
|
|
}, func(m1 *gtsmodel.Tag) *gtsmodel.Tag {
|
|
|
|
m2 := new(gtsmodel.Tag)
|
|
|
|
*m2 = *m1
|
|
|
|
return m2
|
2023-08-03 09:34:35 +00:00
|
|
|
}, cap)
|
|
|
|
|
2023-07-31 13:47:35 +00:00
|
|
|
c.tag.IgnoreErrors(ignoreErrors)
|
|
|
|
}
|
|
|
|
|
2023-10-25 14:04:53 +00:00
|
|
|
func (c *GTSCaches) initThreadMute() {
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeOfThreadMute(), // model in-mem size.
|
|
|
|
config.GetCacheThreadMuteMemRatio(),
|
|
|
|
)
|
|
|
|
|
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
|
|
|
|
|
|
|
c.threadMute = result.New([]result.Lookup{
|
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "ThreadID", Multi: true},
|
|
|
|
{Name: "AccountID", Multi: true},
|
|
|
|
{Name: "ThreadID.AccountID"},
|
|
|
|
}, func(t1 *gtsmodel.ThreadMute) *gtsmodel.ThreadMute {
|
|
|
|
t2 := new(gtsmodel.ThreadMute)
|
|
|
|
*t2 = *t1
|
|
|
|
return t2
|
|
|
|
}, cap)
|
|
|
|
|
|
|
|
c.threadMute.IgnoreErrors(ignoreErrors)
|
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initTombstone() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofTombstone(), // model in-mem size.
|
|
|
|
config.GetCacheTombstoneMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2022-12-16 22:36:52 +00:00
|
|
|
c.tombstone = result.New([]result.Lookup{
|
2022-12-08 17:35:14 +00:00
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "URI"},
|
|
|
|
}, func(t1 *gtsmodel.Tombstone) *gtsmodel.Tombstone {
|
|
|
|
t2 := new(gtsmodel.Tombstone)
|
|
|
|
*t2 = *t1
|
|
|
|
return t2
|
2023-08-03 09:34:35 +00:00
|
|
|
}, cap)
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.tombstone.IgnoreErrors(ignoreErrors)
|
2022-12-08 17:35:14 +00:00
|
|
|
}
|
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initUser() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateResultCacheMax(
|
|
|
|
sizeofUser(), // model in-mem size.
|
|
|
|
config.GetCacheUserMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-11-27 15:39:44 +00:00
|
|
|
copyF := func(u1 *gtsmodel.User) *gtsmodel.User {
|
|
|
|
u2 := new(gtsmodel.User)
|
|
|
|
*u2 = *u1
|
|
|
|
|
|
|
|
// Don't include ptr fields that
|
|
|
|
// will be populated separately.
|
|
|
|
// See internal/db/bundb/user.go.
|
|
|
|
u2.Account = nil
|
|
|
|
|
|
|
|
return u2
|
|
|
|
}
|
|
|
|
|
2022-12-16 22:36:52 +00:00
|
|
|
c.user = result.New([]result.Lookup{
|
2022-12-08 17:35:14 +00:00
|
|
|
{Name: "ID"},
|
|
|
|
{Name: "AccountID"},
|
|
|
|
{Name: "Email"},
|
|
|
|
{Name: "ConfirmationToken"},
|
|
|
|
{Name: "ExternalID"},
|
2023-11-27 15:39:44 +00:00
|
|
|
}, copyF, cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
c.user.IgnoreErrors(ignoreErrors)
|
2022-12-08 17:35:14 +00:00
|
|
|
}
|
2023-03-08 12:57:41 +00:00
|
|
|
|
[performance] refactoring + add fave / follow / request / visibility caching (#1607)
* refactor visibility checking, add caching for visibility
* invalidate visibility cache items on account / status deletes
* fix requester ID passed to visibility cache nil ptr
* de-interface caches, fix home / public timeline caching + visibility
* finish adding code comments for visibility filter
* fix angry goconst linter warnings
* actually finish adding filter visibility code comments for timeline functions
* move home timeline status author check to after visibility
* remove now-unused code
* add more code comments
* add TODO code comment, update printed cache start names
* update printed cache names on stop
* start adding separate follow(request) delete db functions, add specific visibility cache tests
* add relationship type caching
* fix getting local account follows / followed-bys, other small codebase improvements
* simplify invalidation using cache hooks, add more GetAccountBy___() functions
* fix boosting to return 404 if not boostable but no error (to not leak status ID)
* remove dead code
* improved placement of cache invalidation
* update license headers
* add example follow, follow-request config entries
* add example visibility cache configuration to config file
* use specific PutFollowRequest() instead of just Put()
* add tests for all GetAccountBy()
* add GetBlockBy() tests
* update block to check primitive fields
* update and finish adding Get{Account,Block,Follow,FollowRequest}By() tests
* fix copy-pasted code
* update envparsing test
* whitespace
* fix bun struct tag
* add license header to gtscontext
* fix old license header
* improved error creation to not use fmt.Errorf() when not needed
* fix various rebase conflicts, fix account test
* remove commented-out code, fix-up mention caching
* fix mention select bun statement
* ensure mention target account populated, pass in context to customrenderer logging
* remove more uncommented code, fix typeutil test
* add statusfave database model caching
* add status fave cache configuration
* add status fave cache example config
* woops, catch missed error. nice catch linter!
* add back testrig panic on nil db
* update example configuration to match defaults, slight tweak to cache configuration defaults
* update envparsing test with new defaults
* fetch followingget to use the follow target account
* use accounnt.IsLocal() instead of empty domain check
* use constants for the cache visibility type check
* use bun.In() for notification type restriction in db query
* include replies when fetching PublicTimeline() (to account for single-author threads in Visibility{}.StatusPublicTimelineable())
* use bun query building for nested select statements to ensure working with postgres
* update public timeline future status checks to match visibility filter
* same as previous, for home timeline
* update public timeline tests to dynamically check for appropriate statuses
* migrate accounts to allow unique constraint on public_key
* provide minimal account with publicKey
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2023-03-28 13:03:14 +00:00
|
|
|
func (c *GTSCaches) initWebfinger() {
|
2023-08-03 09:34:35 +00:00
|
|
|
// Calculate maximum cache size.
|
|
|
|
cap := calculateCacheMax(
|
|
|
|
sizeofURIStr, sizeofURIStr,
|
|
|
|
config.GetCacheWebfingerMemRatio(),
|
|
|
|
)
|
|
|
|
|
2023-08-14 16:08:19 +00:00
|
|
|
log.Infof(nil, "cache size = %d", cap)
|
2023-08-03 09:34:35 +00:00
|
|
|
|
2023-03-08 12:57:41 +00:00
|
|
|
c.webfinger = ttl.New[string, string](
|
|
|
|
0,
|
2023-08-03 09:34:35 +00:00
|
|
|
cap,
|
|
|
|
24*time.Hour,
|
2023-07-31 10:25:29 +00:00
|
|
|
)
|
2023-03-08 12:57:41 +00:00
|
|
|
}
|