NewMapStorageWithLimit returns an implementation of Storage backed by the contents of given map. Used primarily for testing.
(data DataMap, keyTime map[blob.ID]time.Time, timeNow func() time.Time, limit int64)
| 241 | // NewMapStorageWithLimit returns an implementation of Storage backed by the contents of given map. |
| 242 | // Used primarily for testing. |
| 243 | func NewMapStorageWithLimit(data DataMap, keyTime map[blob.ID]time.Time, timeNow func() time.Time, limit int64) blob.Storage { |
| 244 | if keyTime == nil { |
| 245 | keyTime = make(map[blob.ID]time.Time) |
| 246 | } |
| 247 | |
| 248 | if timeNow == nil { |
| 249 | timeNow = clock.Now |
| 250 | } |
| 251 | |
| 252 | totalBytes := int64(0) |
| 253 | |
| 254 | for _, v := range data { |
| 255 | totalBytes += int64(len(v)) |
| 256 | } |
| 257 | |
| 258 | return &mapStorage{data: data, keyTime: keyTime, timeNow: timeNow, limit: limit, totalBytes: totalBytes} |
| 259 | } |
no outgoing calls