ccache/configuration.go

52 lines
974 B
Go
Raw Normal View History

2013-10-19 02:56:28 +02:00
package ccache
type Configuration struct {
size uint64
buckets int
itemsToPrune int
deleteBuffer int
2013-10-19 02:56:28 +02:00
promoteBuffer int
getsPerPromote int32
2013-10-19 02:56:28 +02:00
}
func Configure() *Configuration {
return &Configuration {
2013-10-19 02:56:28 +02:00
buckets: 64,
itemsToPrune: 500,
deleteBuffer: 1024,
getsPerPromote: 10,
2013-10-19 02:56:28 +02:00
promoteBuffer: 1024,
2013-10-19 14:36:33 +02:00
size: 500 * 1024 * 1024,
2013-10-19 02:56:28 +02:00
}
}
2013-10-19 14:36:33 +02:00
func (c *Configuration) Size(bytes uint64) *Configuration {
c.size = bytes
2013-10-19 02:56:28 +02:00
return c
}
2013-10-19 14:36:33 +02:00
func (c *Configuration) Buckets(count int) *Configuration {
c.buckets = count
2013-10-19 02:56:28 +02:00
return c
}
2013-10-19 14:36:33 +02:00
func (c *Configuration) ItemsToPrune(count int) *Configuration {
c.itemsToPrune = count
2013-10-19 02:56:28 +02:00
return c
}
2013-10-19 14:36:33 +02:00
func (c *Configuration) PromoteBuffer(size int) *Configuration {
c.promoteBuffer = size
2013-10-19 02:56:28 +02:00
return c
}
func (c *Configuration) DeleteBuffer(size int) *Configuration {
c.deleteBuffer = size
return c
}
func (c *Configuration) GetsPerPromote(count int) *Configuration {
c.getsPerPromote = int32(count)
return c
}