# File lib/ramaze/snippets/ramaze/lru_hash.rb, line 138
    def []=(key, obj)
      expire

      invalidate key if key?(key)

      size = Marshal.dump(obj).size

      if max_value && max_value < max_total
        warn "%p isn't cached because it exceeds max_value %p" % [obj, max_value]
        return obj
      end

      if max_value.nil? && max_total && max_total < size
        warn "%p isn't cached because it exceeds max_total: %p" % [obj, max_total]
        return obj
      end

      invalidate list.first if max_count && max_count == list.size

      self.total_size += size

      if max_total
        invalidate list.first until total_size < max_total
      end

      objs[key] = CacheObject.new(obj, size, Time.now.to_i)
      list << key

      obj
    end