public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
Merge branch 'master' of git@github.com:rails/rails
David Heinemeier Hansson (author)
Tue Apr 29 14:43:47 -0700 2008
commit  5514baf63d6d5e19a84c59a0c2cf74f442daed9c
tree    ecde263c340d9fdbcf0f3ba9d9276e38f7fbfb96
parent  0780563ae7b2df74613550f1438d13459cb10b1f parent  5be53058775a1482c1e5655dcb0ca4430cf0dbe1
...
277
278
279
280
281
282
 
 
 
 
283
284
285
...
277
278
279
 
 
 
280
281
282
283
284
285
286
0
@@ -277,9 +277,10 @@
0
     @@debug_routes = true
0
     cattr_accessor :debug_routes
0
 
0
- # Controls whether the application is thread-safe, so multi-threaded servers like WEBrick know whether to apply a mutex
0
- # around the performance of each action. Action Pack and Active Record are by default thread-safe, but many applications
0
- # may not be. Turned off by default.
0
+ # Indicates to Mongrel or Webrick whether to allow concurrent action
0
+ # processing. Your controller actions and any other code they call must
0
+ # also behave well when called from concurrent threads. Turned off by
0
+ # default.
0
     @@allow_concurrency = false
0
     cattr_accessor :allow_concurrency
0
 
...
62
63
64
65
66
67
 
 
68
69
70
...
62
63
64
 
 
 
65
66
67
68
69
0
@@ -62,9 +62,8 @@
0
       assert_equal d, s.cache.get(session_key)[:test]
0
       assert_equal d, s[:test]
0
     end
0
- end
0
-
0
-
0
+ end
0
+
0
   def test_deletion
0
     new_session do |s|
0
       session_key = 'session:' + s.session_id
...
423
424
425
426
 
 
 
427
428
429
...
423
424
425
 
426
427
428
429
430
431
0
@@ -423,7 +423,9 @@
0
     @@default_timezone = :local
0
 
0
     # Determines whether to use a connection for each thread, or a single shared connection for all threads.
0
- # Defaults to false. Set to true if you're writing a threaded application.
0
+ # Defaults to false. If you're writing a threaded application, set to true
0
+ # and periodically call verify_active_connections! to clear out connections
0
+ # assigned to stale threads.
0
     cattr_accessor :allow_concurrency, :instance_writer => false
0
     @@allow_concurrency = false
0
 
...
87
88
89
 
 
 
 
 
 
 
 
 
90
91
 
 
 
 
 
 
 
 
92
93
94
...
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
0
@@ -87,8 +87,25 @@
0
 
0
       def delete_matched(matcher, options = nil)
0
         log("delete matched", matcher.inspect, options)
0
+ end
0
+
0
+ def increment(key, amount = 1)
0
+ log("incrementing", key, amount)
0
+ if num = read(key)
0
+ write(key, num + amount)
0
+ else
0
+ nil
0
+ end
0
       end
0
 
0
+ def decrement(key, amount = 1)
0
+ log("decrementing", key, amount)
0
+ if num = read(key)
0
+ write(key, num - amount)
0
+ else
0
+ nil
0
+ end
0
+ end
0
       
0
       private
0
         def log(operation, key, options)
...
29
30
31
32
33
34
 
 
35
36
37
 
38
39
40
41
42
43
...
49
50
51
 
 
 
 
 
 
 
 
 
52
53
 
 
 
 
 
 
 
 
 
54
55
56
57
58
 
 
59
60
 
 
 
 
61
62
63
...
29
30
31
 
 
 
32
33
34
35
 
36
37
38
39
40
41
42
...
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
 
 
74
75
76
77
78
79
80
81
82
83
84
0
@@ -29,12 +29,11 @@
0
         nil
0
       end
0
 
0
- # Set key = value if key isn't already set. Pass :force => true
0
- # to unconditionally set key = value. Returns a boolean indicating
0
- # whether the key was set.
0
+ # Set key = value. Pass :unless_exist => true if you don't
0
+ # want to update the cache if the key is already set.
0
       def write(key, value, options = nil)
0
         super
0
- method = options && options[:force] ? :set : :add
0
+ method = options && options[:unless_exist] ? :add : :set
0
         response = @data.send(method, key, value, expires_in(options), raw?(options))
0
         response == Response::STORED
0
       rescue MemCache::MemCacheError => e
0
0
0
0
@@ -49,15 +48,37 @@
0
       rescue MemCache::MemCacheError => e
0
         logger.error("MemCacheError (#{e}): #{e.message}")
0
         false
0
+ end
0
+
0
+ def increment(key, amount = 1)
0
+ log("incrementing", key, amount)
0
+
0
+ response = @data.incr(key, amount)
0
+ response == Response::NOT_FOUND ? nil : response
0
+ rescue MemCache::MemCacheError
0
+ nil
0
       end
0
 
0
+ def decrement(key, amount = 1)
0
+ log("decrement", key, amount)
0
+
0
+ response = data.decr(key, amount)
0
+ response == Response::NOT_FOUND ? nil : response
0
+ rescue MemCache::MemCacheError
0
+ nil
0
+ end
0
+
0
       def delete_matched(matcher, options = nil)
0
         super
0
         raise "Not supported by Memcache"
0
- end
0
-
0
+ end
0
+
0
       def clear
0
         @data.flush_all
0
+ end
0
+
0
+ def stats
0
+ @data.stats
0
       end
0
 
0
       private
...
24
25
26
 
 
 
 
27
28
29
...
24
25
26
27
28
29
30
31
32
33
0
@@ -24,6 +24,10 @@
0
         super
0
         @data.delete_if { |k,v| k =~ matcher }
0
       end
0
+
0
+ def clear
0
+ @data.clear
0
+ end
0
     end
0
   end
0
 end
...
135
136
137
138
139
140
141
142
 
 
 
143
144
145
...
135
136
137
 
 
 
138
139
140
141
142
143
144
145
0
@@ -135,11 +135,11 @@
0
 
0
       load_application_initializers
0
 
0
- # Prepare dispatcher callbacks and run 'prepare' callbacks
0
- prepare_dispatcher
0
-
0
       # the framework is now fully initialized
0
       after_initialize
0
+
0
+ # Prepare dispatcher callbacks and run 'prepare' callbacks
0
+ prepare_dispatcher
0
 
0
       # Routing must be initialized after plugins to allow the former to extend the routes
0
       initialize_routing

Comments

    No one has commented yet.