2013-10-19 02:56:28 +02:00
|
|
|
package ccache
|
|
|
|
|
|
|
|
type Configuration struct {
|
2014-02-28 13:10:42 +01:00
|
|
|
size uint64
|
|
|
|
buckets int
|
|
|
|
itemsToPrune int
|
|
|
|
deleteBuffer int
|
|
|
|
promoteBuffer int
|
|
|
|
getsPerPromote int32
|
|
|
|
tracking bool
|
2013-10-19 02:56:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func Configure() *Configuration {
|
2014-02-28 13:10:42 +01:00
|
|
|
return &Configuration{
|
|
|
|
buckets: 64,
|
|
|
|
itemsToPrune: 500,
|
|
|
|
deleteBuffer: 1024,
|
|
|
|
getsPerPromote: 10,
|
|
|
|
promoteBuffer: 1024,
|
|
|
|
size: 500 * 1024 * 1024,
|
|
|
|
tracking: false,
|
|
|
|
}
|
2013-10-19 02:56:28 +02:00
|
|
|
}
|
|
|
|
|
2013-10-19 14:36:33 +02:00
|
|
|
func (c *Configuration) Size(bytes uint64) *Configuration {
|
2014-02-28 13:10:42 +01:00
|
|
|
c.size = bytes
|
|
|
|
return c
|
2013-10-19 02:56:28 +02:00
|
|
|
}
|
|
|
|
|
2013-10-19 14:36:33 +02:00
|
|
|
func (c *Configuration) Buckets(count int) *Configuration {
|
2014-02-28 13:10:42 +01:00
|
|
|
c.buckets = count
|
|
|
|
return c
|
2013-10-19 02:56:28 +02:00
|
|
|
}
|
|
|
|
|
2013-10-19 14:36:33 +02:00
|
|
|
func (c *Configuration) ItemsToPrune(count int) *Configuration {
|
2014-02-28 13:10:42 +01:00
|
|
|
c.itemsToPrune = count
|
|
|
|
return c
|
2013-10-19 02:56:28 +02:00
|
|
|
}
|
|
|
|
|
2013-10-19 14:36:33 +02:00
|
|
|
func (c *Configuration) PromoteBuffer(size int) *Configuration {
|
2014-02-28 13:10:42 +01:00
|
|
|
c.promoteBuffer = size
|
|
|
|
return c
|
2013-10-19 02:56:28 +02:00
|
|
|
}
|
2013-10-30 13:18:51 +01:00
|
|
|
|
|
|
|
func (c *Configuration) DeleteBuffer(size int) *Configuration {
|
2014-02-28 13:10:42 +01:00
|
|
|
c.deleteBuffer = size
|
|
|
|
return c
|
2013-10-30 13:18:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Configuration) GetsPerPromote(count int) *Configuration {
|
2014-02-28 13:10:42 +01:00
|
|
|
c.getsPerPromote = int32(count)
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Configuration) Track() *Configuration {
|
|
|
|
c.tracking = true
|
|
|
|
return c
|
2013-10-30 13:18:51 +01:00
|
|
|
}
|