karlseguin / ccache

A golang LRU Cache for high concurrency
MIT License
1.28k stars 119 forks source link

OnDelete is not called when an item is evicted for size reasons #21

Closed pkaeding closed 5 years ago

pkaeding commented 5 years ago

I might be missing something, but it seems that the OnDelete callback is not called when an item is removed because the size limit is reached. I think we'd just need to add these lines into the gc function:

if c.onDelete != nil {
    c.onDelete(item)
}

Does that sound right?

karlseguin commented 5 years ago

I think so, @alexejk agree?

alexejk commented 5 years ago

Sounds reasonable. I've sent a PR to fix that & a test to cover it

karlseguin commented 5 years ago

thanks!