func (c *Cache) GetRateLimitAllocation() uint64 {
  return atomic.LoadUint64(&c.requestCounter)
}
retrieves the amount of requests which have been submitted to the upstream servers within the
last minute
package cache
import (
  "sync"
  "sync/atomic"
  "time"
  "github.com/dotStart/Stockpile/entity"
  "github.com/dotStart/Stockpile/stockpile/mojang"
  "github.com/dotStart/Stockpile/stockpile/storage"
  "github.com/op/go-logging"
)
type Cache struct {
  logger   *logging.Logger
  upstream *mojang.MojangAPI
  storage  storage.StorageBackend
  resetTicker    *time.Ticker
  requestCounter uint64
  events         chan *entity.Event
  listenerMutex *sync.Mutex
  listeners     []*Listener
}
func New(upstream *mojang.MojangAPI, storage storage.StorageBackend) *Cache {
  cache := &Cache{
    logger:        logging.MustGetLogger("cache"),
    upstream:      upstream,
    storage:       storage,
    resetTicker:   time.NewTicker(time.Minute * 10),
    events:        make(chan *entity.Event),
    listenerMutex: &sync.Mutex{},
    listeners:     make([]*Listener, 0),
  }
  go cache.deliverEvents()
  go cache.resetRequestCounter()
  return cache
}
func (c *Cache) incrementRequestCounter() {
  c.logger.Debugf("Incremented request counter")
  atomic.AddUint64(&c.requestCounter, 1)
}
func (c *Cache) resetRequestCounter() {
  for range c.resetTicker.C {
    atomic.StoreUint64(&c.requestCounter, 0)
  }
}