allegro / allegro/bigcache

Set failure even when there is enough memory left and size of entry is acceptable

Abierto
#214 2 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
Go
Estrellas
8.2k
Forks
614
Merge medio
5 d 12 h
PR fusionados (30 d)
1

Descripción

**What is the issue you are having?**
Set failing with `entry is bigger than max shard size`(2MB) even when there is enough memory left and size of entry is acceptable (38 kb)

**What is BigCache doing that it shouldn't?**
[Error in question](https://github.com/allegro/bigcache/blob/master/shard.go#L147)

Reason [removeOldestEntry](https://github.com/allegro/bigcache/blob/master/shard.go#L145) returned an error

Which was in-turn returned by [Pop](https://github.com/allegro/bigcache/blob/master/shard.go#L292)

[Pop](https://github.com/allegro/bigcache/blob/master/queue/bytes_queue.go#L159) will only return an error if `peek` fails

[Peek](https://github.com/allegro/bigcache/blob/master/queue/bytes_queue.go#L229) `can` return an error if the [queue is empty](https://github.com/allegro/bigcache/blob/master/queue/bytes_queue.go#L215)

`entry is bigger than max shard size` is not the correct error

**Minimal, Complete, and Verifiable Example**
Not able to reproduce it
```
config := &bigcache.Config{
LifeWindow: 2 * time.Hour,
CleanWindow: 1 * time.Second,
HardMaxCacheSize: 1024 * 2,
Shards: 1024,
}
```
But was reading the code and thought this could be one of the reason

When asking a question about a problem caused by your code, you will get much better answers if you provide code we can use to reproduce the problem. That code should be...

* ...Minimal – Use as little code as possible that still produces the same problem
* ...Complete – Provide all parts needed to reproduce the problem
* ...Verifiable – Test the code you're about to provide to make sure it reproduces the problem

For more information on how to provide an MCVE, please see the [Stack Overflow documentation](https://stackoverflow.com/help/mcve).

**Environment:**
- Version (git sha or release):
- OS (e.g. from `/etc/os-release` or winver.exe):
- go version:

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.