MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / createMemoryStorage

Method createMemoryStorage

internal/caches/storage_file.go:1505–1535  ·  view source on GitHub ↗

创建当前策略包含的内存缓存

()

Source from the content-addressed store, hash-verified

1503
1504// 创建当前策略包含的内存缓存
1505func (this *FileStorage) createMemoryStorage() error {
1506 var memoryPolicy = &serverconfigs.HTTPCachePolicy{
1507 Id: this.policy.Id,
1508 IsOn: this.policy.IsOn,
1509 Name: this.policy.Name,
1510 Description: this.policy.Description,
1511 Capacity: this.options.MemoryPolicy.Capacity,
1512 MaxSize: &shared.SizeCapacity{Count: 128, Unit: shared.SizeCapacityUnitMB}, // TODO 将来可以修改
1513 Type: serverconfigs.CachePolicyStorageMemory,
1514 Options: this.policy.Options,
1515 Life: this.policy.Life,
1516 MinLife: this.policy.MinLife,
1517 MaxLife: this.policy.MaxLife,
1518
1519 MemoryAutoPurgeCount: this.policy.MemoryAutoPurgeCount,
1520 MemoryAutoPurgeInterval: this.policy.MemoryAutoPurgeInterval,
1521 MemoryLFUFreePercent: this.policy.MemoryLFUFreePercent,
1522 }
1523 err := memoryPolicy.Init()
1524 if err != nil {
1525 return err
1526 }
1527 var memoryStorage = NewMemoryStorage(memoryPolicy, this)
1528 err = memoryStorage.Init()
1529 if err != nil {
1530 return err
1531 }
1532 this.memoryStorage = memoryStorage
1533
1534 return nil
1535}
1536
1537func (this *FileStorage) initPurgeTicker() {
1538 var autoPurgeInterval = this.policy.PersistenceAutoPurgeInterval

Callers 2

UpdatePolicyMethod · 0.95
InitMethod · 0.95

Calls 2

NewMemoryStorageFunction · 0.85
InitMethod · 0.65

Tested by

no test coverage detected