It's not extended twice, the expires_in is set to the value without
race_ttl -> we need to add it or we would set expires_in => 0 in the .write


On Tue, Oct 15, 2013 at 4:39 PM, Christopher Cocchi-Perrier <
notifications@github.com> wrote:

> In lib/active_support/cache/libmemcached_store.rb:
>
> > +      def fetch_with_race_condition_ttl(key, options={}, &block)
> > +        options = options.dup
> > +
> > +        race_ttl = options.delete(:race_condition_ttl) || raise("Use :race_condition_ttl option or normal fetch")
> > +        expires_in = options.fetch(:expires_in)
> > +        options[:expires_in] = expires_in + race_ttl
> > +        options[:preserve_race_condition_entry] = true
> > +
> > +        value = fetch(key, options) { FetchWithRaceConditionTTLEntry.new(yield, expires_in) }
> > +
> > +        return value if !value.nil? && !value.is_a?(FetchWithRaceConditionTTLEntry
> )
> > +
> > +        if value.expired? && !value.extended
> > +          # we take care of refreshing the cache, all others should keep reading
> > +          value.extended = true
> > +          write(key, value, options.merge(:expires_in => value.expires_in + race_ttl))
>
> You may not need to re-add the race_ttl here since the only case where
> you can be in this block is if the value has expired *and* the key has
> not been evicted from memcached yet, so you are already in the race
> condition overtime. It looks odd to add extend it twice (and may lead to
> unwanted behaviors)
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/ccocchi/libmemcached_store/pull/12/files#r6988743>
> .
>