Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8765

Show
Ignore:
Timestamp:
02/01/08 07:07:56 (7 months ago)
Author:
bitsweat
Message:

MemCacheStore#write uses add by default and set if :force => true

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/lib/active_support/cache/mem_cache_store.rb

    r8687 r8765  
    2121      end 
    2222 
    23       def write(key, value, options = nil) 
     23      # Set key = value if key isn't already set. Pass :force => true 
     24      # to unconditionally set key = value. 
     25      def write(key, value, options = {}) 
    2426        super 
    25         @data.set(key, value, expires_in(options), raw?(options)) 
     27        method = options[:force] ? :set : :add 
     28        @data.send(method, key, value, expires_in(options), raw?(options)) 
    2629      rescue MemCache::MemCacheError => e 
    2730        logger.error("MemCacheError (#{e}): #{e.message}")