Skip to content

Commit

Permalink
Adds additional logs for the size of observables in the Local Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorpamplona committed Jul 17, 2024
1 parent bc6d506 commit 5e42fa5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ object LocalCache {

val deletionIndex = DeletionIndex()

private val observablesByKindAndETag = ConcurrentHashMap<Int, ConcurrentHashMap<HexKey, LatestByKindWithETag<Event>>>(10)
private val observablesByKindAndAuthor = ConcurrentHashMap<Int, ConcurrentHashMap<HexKey, LatestByKindAndAuthor<Event>>>(10)
val observablesByKindAndETag = ConcurrentHashMap<Int, ConcurrentHashMap<HexKey, LatestByKindWithETag<Event>>>(10)
val observablesByKindAndAuthor = ConcurrentHashMap<Int, ConcurrentHashMap<HexKey, LatestByKindAndAuthor<Event>>>(10)

fun <T : Event> observeETag(
kind: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,18 @@ fun debugState(context: Context) {
" / " +
LocalCache.users.size(),
)
Log.d(
"STATE DUMP",
"Deletion Events: " +
LocalCache.deletionIndex.size(),
)
Log.d(
"STATE DUMP",
"Observable Events: " +
LocalCache.observablesByKindAndETag.size +
" / " +
LocalCache.observablesByKindAndAuthor.size,
)

Log.d(
"STATE DUMP",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ class DeletionIndex {
val deletionEvent = deletedReferencesBefore.get(key)
return deletionEvent != null && createdAt <= deletionEvent.createdAt
}

fun size() = deletedReferencesBefore.size()
}

0 comments on commit 5e42fa5

Please sign in to comment.