Skip to content

memory adapter: infinite loop if initial object is larger than max cache size #25

@kris-watts-gravwell

Description

@kris-watts-gravwell

Tested on:

v0.0.0-20240523143319-7d9f48f8ab91

How to reproduce:

  1. create a cache middleware using the memory adapter with a size of X
  2. Make an initial request with a response of size 2X

What happens:

  1. HTTP response never happens and CPU goes to 100%

Code trail:

in adapter/memory/memory.go:136 there is a for loop that will call evict until a.storage.shouldEvict(len(response)) is false, however if the cache is empty or if the response is larger than the cache size the loop will never exit because the evict call will never do anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions