Pushed fixes for the other comments, looking good ?


On Tue, Oct 15, 2013 at 5:14 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))
>
> The value is set without the race_tll only in the
> FetchWithRaceConditionTTLEntry class. For memcached, the expires_in is
> set like that options[:expires_in] = expires_in + race_ttl. So to have
> the case when value.expired? is true and the value still in memcached,
> you already are in the race_ttl overtime.
>
> But you're right, since value.expired_in will be negative, adding again
> the race_ttl will conserve approximatively the same expiration inside
> memcached which is better than to have non time limited keys.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/ccocchi/libmemcached_store/pull/12/files#r6989363>
> .
>