func (c *TwoQueue) Get(key uint64) (interface{}, bool) {
	if val, ok := c.frequent.Get(key); ok {
		return val, ok
	}
	if val, ok := c.recent.Peek(key); ok {
		c.recent.Remove(key)
		c.frequent.Put(key, val)
		return val, ok
	}
	return nil, false
}
Get retrieves an item from cache.
package cache
const (
	defaultRecentRatio float64 = 0.25
	defaultGhostRatio float64 = 0.50
)
type TwoQueue struct {
	size       int
	recentSize int
	recent   *LRU
	frequent *LRU
	ghost    *LRU
}
func newTwoQueue(size int) *TwoQueue {
	return newTwoQueueParams(size, defaultRecentRatio, defaultGhostRatio)
}
func newTwoQueueParams(size int, recentRatio, ghostRatio float64) *TwoQueue {
	recentSize := int(float64(size) * recentRatio)
	ghostSize := int(float64(size) * ghostRatio)
	return &TwoQueue{
		size:       size,
		recentSize: recentSize,
		recent:     newLRU(size),
		frequent:   newLRU(size),
		ghost:      newLRU(ghostSize),
	}
}
func (c *TwoQueue) Put(key uint64, value interface{}) {
	if c.frequent.contains(key) {
		c.frequent.Put(key, value)
		return
	}
	if c.recent.contains(key) {
		c.recent.Remove(key)
		c.frequent.Put(key, value)
		return
	}
	if c.ghost.contains(key) {
		c.ensureSpace(true)
		c.ghost.Remove(key)
		c.frequent.Put(key, value)
		return
	}
	c.ensureSpace(false)
	c.recent.Put(key, value)
}
func (c *TwoQueue) ensureSpace(ghost bool) {
	recentLen := c.recent.Len()
	frequentLen := c.frequent.Len()
	if recentLen+frequentLen < c.size {
		return
	}
	if recentLen > 0 && (recentLen > c.recentSize || (recentLen == c.recentSize && !ghost)) {
		k, _, _ := c.recent.getAndRemoveOldest()
		c.ghost.Put(k, nil)
		return
	}
	c.frequent.removeOldest()
}