mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-07 03:17:50 +00:00
add cache
This commit is contained in:
parent
3c399bc533
commit
c812cca58e
2 changed files with 7 additions and 3 deletions
8
api.go
8
api.go
|
|
@ -59,6 +59,8 @@ type API struct {
|
|||
importWorkerPoolSize int
|
||||
importWork chan importJob
|
||||
|
||||
usageCache map[string]NodeUsage
|
||||
|
||||
Serializer Serializer
|
||||
}
|
||||
|
||||
|
|
@ -934,9 +936,11 @@ func (api *API) Usage(ctx context.Context, remote bool) (map[string]NodeUsage, e
|
|||
span, _ := tracing.StartSpanFromContext(ctx, "API.Usage")
|
||||
defer span.Finish()
|
||||
|
||||
nodeUsages := make(map[string]NodeUsage)
|
||||
if api.usageCache == nil {
|
||||
api.usageCache = make(map[string]NodeUsage)
|
||||
}
|
||||
|
||||
indexDetails, nodeMetadataBytes, err := api.holder.Txf().IndexUsageDetails()
|
||||
indexDetails, nodeMetadataBytes, err := api.holder.Txf().IndexUsageDetails(api.usageCache[api.server.nodeID].Disk.IndexUsage)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting node usage")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -572,7 +572,7 @@ func (f *TxFactory) DumpAll() {
|
|||
|
||||
// IndexUsageDetails computes the sum of filesizes used by the node, broken down
|
||||
// by index, field, fragments and keys.
|
||||
func (f *TxFactory) IndexUsageDetails() (map[string]IndexUsage, uint64, error) {
|
||||
func (f *TxFactory) IndexUsageDetails(cache *map[string]IndexUsage) (map[string]IndexUsage, uint64, error) {
|
||||
indexUsage := make(map[string]IndexUsage)
|
||||
holderPath, err := expandDirName(f.holder.path)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue