Skip to content
Snippets Groups Projects
Unverified Commit e788ca53 authored by Jonas Theis's avatar Jonas Theis Committed by GitHub
Browse files

Adjust cache time of object storage (#490)

parent 1ba191f2
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,8 @@ const (
osChildBranch
osConflict
osConflictMember
cacheTime = 30 * time.Second
)
var (
......@@ -24,23 +26,23 @@ var (
})
osBranchOptions = []objectstorage.Option{
objectstorage.CacheTime(60 * time.Second),
objectstorage.CacheTime(cacheTime),
osLeakDetectionOption,
}
osChildBranchOptions = []objectstorage.Option{
objectstorage.CacheTime(60 * time.Second),
objectstorage.CacheTime(cacheTime),
objectstorage.PartitionKey(BranchIDLength, BranchIDLength),
osLeakDetectionOption,
}
osConflictOptions = []objectstorage.Option{
objectstorage.CacheTime(60 * time.Second),
objectstorage.CacheTime(cacheTime),
osLeakDetectionOption,
}
osConflictMemberOptions = []objectstorage.Option{
objectstorage.CacheTime(60 * time.Second),
objectstorage.CacheTime(cacheTime),
objectstorage.PartitionKey(ConflictIDLength, BranchIDLength),
osLeakDetectionOption,
}
......
......@@ -22,6 +22,8 @@ const (
osAttachment
osOutput
osConsumer
cacheTime = 20 * time.Second
)
var (
......
......@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"math"
"time"
"github.com/iotaledger/hive.go/async"
"github.com/iotaledger/hive.go/events"
......@@ -50,15 +49,15 @@ func New(store kvstore.KVStore) (tangle *Tangle) {
tangle = &Tangle{
branchManager: branchmanager.New(store),
payloadStorage: osFactory.New(osPayload, osPayloadFactory, objectstorage.CacheTime(1*time.Second)),
payloadMetadataStorage: osFactory.New(osPayloadMetadata, osPayloadMetadataFactory, objectstorage.CacheTime(1*time.Second)),
missingPayloadStorage: osFactory.New(osMissingPayload, osMissingPayloadFactory, objectstorage.CacheTime(1*time.Second)),
approverStorage: osFactory.New(osApprover, osPayloadApproverFactory, objectstorage.CacheTime(1*time.Second), objectstorage.PartitionKey(payload.IDLength, payload.IDLength), objectstorage.KeysOnly(true)),
transactionStorage: osFactory.New(osTransaction, osTransactionFactory, objectstorage.CacheTime(1*time.Second), osLeakDetectionOption),
transactionMetadataStorage: osFactory.New(osTransactionMetadata, osTransactionMetadataFactory, objectstorage.CacheTime(1*time.Second), osLeakDetectionOption),
attachmentStorage: osFactory.New(osAttachment, osAttachmentFactory, objectstorage.CacheTime(1*time.Second), objectstorage.PartitionKey(transaction.IDLength, payload.IDLength), osLeakDetectionOption),
outputStorage: osFactory.New(osOutput, osOutputFactory, OutputKeyPartitions, objectstorage.CacheTime(1*time.Second), osLeakDetectionOption),
consumerStorage: osFactory.New(osConsumer, osConsumerFactory, ConsumerPartitionKeys, objectstorage.CacheTime(1*time.Second), osLeakDetectionOption),
payloadStorage: osFactory.New(osPayload, osPayloadFactory, objectstorage.CacheTime(cacheTime)),
payloadMetadataStorage: osFactory.New(osPayloadMetadata, osPayloadMetadataFactory, objectstorage.CacheTime(cacheTime)),
missingPayloadStorage: osFactory.New(osMissingPayload, osMissingPayloadFactory, objectstorage.CacheTime(cacheTime)),
approverStorage: osFactory.New(osApprover, osPayloadApproverFactory, objectstorage.CacheTime(cacheTime), objectstorage.PartitionKey(payload.IDLength, payload.IDLength), objectstorage.KeysOnly(true)),
transactionStorage: osFactory.New(osTransaction, osTransactionFactory, objectstorage.CacheTime(cacheTime), osLeakDetectionOption),
transactionMetadataStorage: osFactory.New(osTransactionMetadata, osTransactionMetadataFactory, objectstorage.CacheTime(cacheTime), osLeakDetectionOption),
attachmentStorage: osFactory.New(osAttachment, osAttachmentFactory, objectstorage.CacheTime(cacheTime), objectstorage.PartitionKey(transaction.IDLength, payload.IDLength), osLeakDetectionOption),
outputStorage: osFactory.New(osOutput, osOutputFactory, OutputKeyPartitions, objectstorage.CacheTime(cacheTime), osLeakDetectionOption),
consumerStorage: osFactory.New(osConsumer, osConsumerFactory, ConsumerPartitionKeys, objectstorage.CacheTime(cacheTime), osLeakDetectionOption),
Events: *newEvents(),
}
......
......@@ -21,6 +21,8 @@ const (
// MissingCheckInterval is the interval on which it is checked whether a missing
// message is still missing.
MissingCheckInterval = 5 * time.Second
cacheTime = 20 * time.Second
)
// Tangle represents the base layer of messages.
......@@ -55,10 +57,10 @@ func New(store kvstore.KVStore) (result *Tangle) {
result = &Tangle{
shutdown: make(chan struct{}),
messageStorage: osFactory.New(PrefixMessage, messageFactory, objectstorage.CacheTime(10*time.Second), objectstorage.LeakDetectionEnabled(false)),
messageMetadataStorage: osFactory.New(PrefixMessageMetadata, MessageMetadataFromStorageKey, objectstorage.CacheTime(10*time.Second), objectstorage.LeakDetectionEnabled(false)),
approverStorage: osFactory.New(PrefixApprovers, approverFactory, objectstorage.CacheTime(10*time.Second), objectstorage.PartitionKey(message.IdLength, message.IdLength), objectstorage.LeakDetectionEnabled(false)),
missingMessageStorage: osFactory.New(PrefixMissingMessage, missingMessageFactory, objectstorage.CacheTime(10*time.Second), objectstorage.LeakDetectionEnabled(false)),
messageStorage: osFactory.New(PrefixMessage, messageFactory, objectstorage.CacheTime(cacheTime), objectstorage.LeakDetectionEnabled(false)),
messageMetadataStorage: osFactory.New(PrefixMessageMetadata, MessageMetadataFromStorageKey, objectstorage.CacheTime(cacheTime), objectstorage.LeakDetectionEnabled(false)),
approverStorage: osFactory.New(PrefixApprovers, approverFactory, objectstorage.CacheTime(cacheTime), objectstorage.PartitionKey(message.IdLength, message.IdLength), objectstorage.LeakDetectionEnabled(false)),
missingMessageStorage: osFactory.New(PrefixMissingMessage, missingMessageFactory, objectstorage.CacheTime(cacheTime), objectstorage.LeakDetectionEnabled(false)),
Events: *newEvents(),
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment