On Thu, Jan 27, 2011 at 1:07 PM, Benoit Chesneau <[email protected]> wrote:
>
> However I'm not sure that if someone set a new size > cache_size then
> Count is < 0 and will create an error. I will put the guard on top and
> match (_) for that.

handle_call({new_max_cache_size, NewSize},
        _From, #state{cache_size = Size} = State) when NewSize >= Size ->
    {reply, ok, State#state{max_cache_size = NewSize}};

handle_call({new_max_cache_size, NewSize}, _From, State) ->
    free_mru_cache_entries(State#state.cache_size - NewSize),
    {reply, ok, State#state{max_cache_size = NewSize, cache_size = NewSize}};

Please read the surrounding code :)

>
> -benoît
>



-- 
Filipe David Manana,
[email protected], [email protected]

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Reply via email to