forked from TrueCloudLab/frostfs-s3-gw
[#405] English Check
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
This commit is contained in:
parent
a0a04a73bd
commit
bf38007692
42 changed files with 205 additions and 205 deletions
8
api/cache/accessbox.go
vendored
8
api/cache/accessbox.go
vendored
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
type (
|
||||
// AccessBoxCache stores access box by its address.
|
||||
// AccessBoxCache stores an access box by its address.
|
||||
AccessBoxCache struct {
|
||||
cache gcache.Cache
|
||||
}
|
||||
|
@ -24,11 +24,11 @@ type (
|
|||
const (
|
||||
// DefaultAccessBoxCacheSize is a default maximum number of entries in cache.
|
||||
DefaultAccessBoxCacheSize = 100
|
||||
// DefaultAccessBoxCacheLifetime is a default lifetime of entries in cache.
|
||||
// DefaultAccessBoxCacheLifetime is a default lifetime of entries in cache.
|
||||
DefaultAccessBoxCacheLifetime = 10 * time.Minute
|
||||
)
|
||||
|
||||
// DefaultAccessBoxConfig return new default cache expiration values.
|
||||
// DefaultAccessBoxConfig returns new default cache expiration values.
|
||||
func DefaultAccessBoxConfig() *Config {
|
||||
return &Config{Size: DefaultAccessBoxCacheSize, Lifetime: DefaultAccessBoxCacheLifetime}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ func NewAccessBoxCache(config *Config) *AccessBoxCache {
|
|||
return &AccessBoxCache{cache: gc}
|
||||
}
|
||||
|
||||
// Get returns cached object.
|
||||
// Get returns a cached object.
|
||||
func (o *AccessBoxCache) Get(address *address.Address) *accessbox.Box {
|
||||
entry, err := o.cache.Get(address.String())
|
||||
if err != nil {
|
||||
|
|
8
api/cache/buckets.go
vendored
8
api/cache/buckets.go
vendored
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/nspcc-dev/neofs-s3-gw/api/data"
|
||||
)
|
||||
|
||||
// BucketCache contains cache with objects and lifetime of cache entries.
|
||||
// BucketCache contains cache with objects and the lifetime of cache entries.
|
||||
type BucketCache struct {
|
||||
cache gcache.Cache
|
||||
}
|
||||
|
@ -15,11 +15,11 @@ type BucketCache struct {
|
|||
const (
|
||||
// DefaultBucketCacheSize is a default maximum number of entries in cache.
|
||||
DefaultBucketCacheSize = 1e3
|
||||
// DefaultBucketCacheLifetime is a default lifetime of entries in cache.
|
||||
// DefaultBucketCacheLifetime is a default lifetime of entries in cache.
|
||||
DefaultBucketCacheLifetime = time.Minute
|
||||
)
|
||||
|
||||
// DefaultBucketConfig return new default cache expiration values.
|
||||
// DefaultBucketConfig returns new default cache expiration values.
|
||||
func DefaultBucketConfig() *Config {
|
||||
return &Config{Size: DefaultBucketCacheSize, Lifetime: DefaultBucketCacheLifetime}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ func NewBucketCache(config *Config) *BucketCache {
|
|||
return &BucketCache{cache: gc}
|
||||
}
|
||||
|
||||
// Get returns cached object.
|
||||
// Get returns a cached object.
|
||||
func (o *BucketCache) Get(key string) *data.BucketInfo {
|
||||
entry, err := o.cache.Get(key)
|
||||
if err != nil {
|
||||
|
|
10
api/cache/names.go
vendored
10
api/cache/names.go
vendored
|
@ -7,8 +7,8 @@ import (
|
|||
"github.com/nspcc-dev/neofs-sdk-go/object/address"
|
||||
)
|
||||
|
||||
// ObjectsNameCache provides for lru cache for objects.
|
||||
// This cache contains mapping nice name to object addresses.
|
||||
// ObjectsNameCache provides lru cache for objects.
|
||||
// This cache contains mapping nice names to object addresses.
|
||||
// Key is bucketName+objectName.
|
||||
type ObjectsNameCache struct {
|
||||
cache gcache.Cache
|
||||
|
@ -17,11 +17,11 @@ type ObjectsNameCache struct {
|
|||
const (
|
||||
// DefaultObjectsNameCacheSize is a default maximum number of entries in cache.
|
||||
DefaultObjectsNameCacheSize = 1e4
|
||||
// DefaultObjectsNameCacheLifetime is a default lifetime of entries in cache.
|
||||
// DefaultObjectsNameCacheLifetime is a default lifetime of entries in cache.
|
||||
DefaultObjectsNameCacheLifetime = time.Minute
|
||||
)
|
||||
|
||||
// DefaultObjectsNameConfig return new default cache expiration values.
|
||||
// DefaultObjectsNameConfig returns new default cache expiration values.
|
||||
func DefaultObjectsNameConfig() *Config {
|
||||
return &Config{Size: DefaultObjectsNameCacheSize, Lifetime: DefaultObjectsNameCacheLifetime}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func NewObjectsNameCache(config *Config) *ObjectsNameCache {
|
|||
return &ObjectsNameCache{cache: gc}
|
||||
}
|
||||
|
||||
// Get returns cached object.
|
||||
// Get returns a cached object.
|
||||
func (o *ObjectsNameCache) Get(key string) *address.Address {
|
||||
entry, err := o.cache.Get(key)
|
||||
if err != nil {
|
||||
|
|
6
api/cache/objects.go
vendored
6
api/cache/objects.go
vendored
|
@ -16,11 +16,11 @@ type ObjectsCache struct {
|
|||
const (
|
||||
// DefaultObjectsCacheLifetime is a default lifetime of entries in objects' cache.
|
||||
DefaultObjectsCacheLifetime = time.Minute * 5
|
||||
// DefaultObjectsCacheSize is a default maximum number of entries in objects' in cache.
|
||||
// DefaultObjectsCacheSize is a default maximum number of entries in objects' cache.
|
||||
DefaultObjectsCacheSize = 1e6
|
||||
)
|
||||
|
||||
// DefaultObjectsConfig return new default cache expiration values.
|
||||
// DefaultObjectsConfig returns new default cache expiration values.
|
||||
func DefaultObjectsConfig() *Config {
|
||||
return &Config{Size: DefaultObjectsCacheSize, Lifetime: DefaultObjectsCacheLifetime}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ func New(config *Config) *ObjectsCache {
|
|||
return &ObjectsCache{cache: gc}
|
||||
}
|
||||
|
||||
// Get returns cached object.
|
||||
// Get returns a cached object.
|
||||
func (o *ObjectsCache) Get(address *address.Address) *object.Object {
|
||||
entry, err := o.cache.Get(address.String())
|
||||
if err != nil {
|
||||
|
|
16
api/cache/objectslist.go
vendored
16
api/cache/objectslist.go
vendored
|
@ -11,16 +11,16 @@ import (
|
|||
)
|
||||
|
||||
/*
|
||||
This is an implementation of a cache which keeps unsorted lists of objects' IDs (all versions)
|
||||
This is an implementation of cache which keeps unsorted lists of objects' IDs (all versions)
|
||||
for a specified bucket and a prefix.
|
||||
|
||||
The cache contains gcache whose entries have a key: ObjectsListKey struct and a value: list of ids.
|
||||
After putting a record it lives for a while (default value is 60 seconds).
|
||||
After putting a record, it lives for a while (default value is 60 seconds).
|
||||
|
||||
When we receive a request from the user we try to find the suitable and non-expired cache entry, go through the list
|
||||
When we receive a request from a user, we try to find the suitable and non-expired cache entry, go through the list
|
||||
and get ObjectInfos from common object cache or with a request to NeoFS.
|
||||
|
||||
When we put an object into a container we invalidate entries with prefixes that are prefixes of the object's name.
|
||||
When we put an object into a container, we invalidate entries with prefixes that are prefixes of the object's name.
|
||||
*/
|
||||
|
||||
type (
|
||||
|
@ -43,18 +43,18 @@ const (
|
|||
DefaultObjectsListCacheSize = 1e5
|
||||
)
|
||||
|
||||
// DefaultObjectsListConfig return new default cache expiration values.
|
||||
// DefaultObjectsListConfig returns new default cache expiration values.
|
||||
func DefaultObjectsListConfig() *Config {
|
||||
return &Config{Size: DefaultObjectsListCacheSize, Lifetime: DefaultObjectsListCacheLifetime}
|
||||
}
|
||||
|
||||
// NewObjectsListCache is a constructor which creates an object of ListObjectsCache with given lifetime of entries.
|
||||
// NewObjectsListCache is a constructor which creates an object of ListObjectsCache with the given lifetime of entries.
|
||||
func NewObjectsListCache(config *Config) *ObjectsListCache {
|
||||
gc := gcache.New(config.Size).LRU().Expiration(config.Lifetime).Build()
|
||||
return &ObjectsListCache{cache: gc}
|
||||
}
|
||||
|
||||
// Get return list of ObjectInfo.
|
||||
// Get returns a list of ObjectInfo.
|
||||
func (l *ObjectsListCache) Get(key ObjectsListKey) []oid.ID {
|
||||
entry, err := l.cache.Get(key)
|
||||
if err != nil {
|
||||
|
@ -93,7 +93,7 @@ func (l *ObjectsListCache) CleanCacheEntriesContainingObject(objectName string,
|
|||
}
|
||||
}
|
||||
|
||||
// CreateObjectsListCacheKey returns ObjectsListKey with given CID and prefix.
|
||||
// CreateObjectsListCacheKey returns ObjectsListKey with the given CID and prefix.
|
||||
func CreateObjectsListCacheKey(cid *cid.ID, prefix string) ObjectsListKey {
|
||||
p := ObjectsListKey{
|
||||
cid: cid.String(),
|
||||
|
|
6
api/cache/system.go
vendored
6
api/cache/system.go
vendored
|
@ -17,11 +17,11 @@ type SystemCache struct {
|
|||
const (
|
||||
// DefaultSystemCacheSize is a default maximum number of entries in cache.
|
||||
DefaultSystemCacheSize = 1e4
|
||||
// DefaultSystemCacheLifetime is a default lifetime of entries in cache.
|
||||
// DefaultSystemCacheLifetime is a default lifetime of entries in cache.
|
||||
DefaultSystemCacheLifetime = 5 * time.Minute
|
||||
)
|
||||
|
||||
// DefaultSystemConfig return new default cache expiration values.
|
||||
// DefaultSystemConfig returns new default cache expiration values.
|
||||
func DefaultSystemConfig() *Config {
|
||||
return &Config{Size: DefaultSystemCacheSize, Lifetime: DefaultSystemCacheLifetime}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func NewSystemCache(config *Config) *SystemCache {
|
|||
return &SystemCache{cache: gc}
|
||||
}
|
||||
|
||||
// GetObject returns cached object.
|
||||
// GetObject returns a cached object.
|
||||
func (o *SystemCache) GetObject(key string) *data.ObjectInfo {
|
||||
entry, err := o.cache.Get(key)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue