'How to find the memory consumed by IDistributed in-memory cache in a deployed application? can we monitor that someway

i am using in-memory distributed cache as per this documentation -

https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed?view=aspnetcore-6.0#distributed-memory-cache

in the following documentation i am using IDistributedCache implementation with Distributed memory cache

Is there a way to monitor the memory usage in a deployed environment and also in local environments? I haven't found any source online.



Solution 1:[1]

Use the default property first{ condition }

    let id = 4
    
    let roster: [TeamMember] = [.init(id: 1, name: "Abishek", age: 19),
                               .init(id: 2, name: "Dinesh", age: 22),
                               .init(id: 3, name: "Praveen", age: 24),
                               .init(id: 4, name: "Sam", age: 25),
                               .init(id: 5, name: "David", age: 21)]
let firstMember = roster.first{$0.id == id}

print(firstMember)
print(firstMember?.name)

Output

Optional(TeamMember(id: 4, name: "Sam", age: 25.0))
Optional("Sam")

Solution 2:[2]

let name = team.roster.first(where: { $0["player_id"] == id}).map{ $0["player_name"] }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Abishek Thangaraj
Solution 2 Shabnam Siddiqui