提交 d2149256 编写于 作者: N Neeraj Singh

making comments meaningful by correcting, adding and pruning

上级 c77adb40
...@@ -16,8 +16,7 @@ module Cache ...@@ -16,8 +16,7 @@ module Cache
# Special features: # Special features:
# - Clustering and load balancing. One can specify multiple memcached servers, # - Clustering and load balancing. One can specify multiple memcached servers,
# and MemCacheStore will load balance between all available servers. If a # and MemCacheStore will load balance between all available servers. If a
# server goes down, then MemCacheStore will ignore it until it goes back # server goes down, then MemCacheStore will ignore it until it comes back up.
# online.
# #
# MemCacheStore implements the Strategy::LocalCache strategy which implements # MemCacheStore implements the Strategy::LocalCache strategy which implements
# an in memory cache inside of a block. # an in memory cache inside of a block.
...@@ -69,7 +68,7 @@ def initialize(*addresses) ...@@ -69,7 +68,7 @@ def initialize(*addresses)
extend LocalCacheWithRaw extend LocalCacheWithRaw
end end
# Reads multiple keys from the cache using a single call to the # Reads multiple values from the cache using a single call to the
# servers for all keys. Options can be passed in the last argument. # servers for all keys. Options can be passed in the last argument.
def read_multi(*names) def read_multi(*names)
options = names.extract_options! options = names.extract_options!
...@@ -113,7 +112,7 @@ def decrement(name, amount = 1, options = nil) # :nodoc: ...@@ -113,7 +112,7 @@ def decrement(name, amount = 1, options = nil) # :nodoc:
end end
# Clear the entire cache on all memcached servers. This method should # Clear the entire cache on all memcached servers. This method should
# be used with care when using a shared cache. # be used with care when shared cache is being used.
def clear(options = nil) def clear(options = nil)
@data.flush_all @data.flush_all
end end
......
...@@ -5,9 +5,9 @@ module Cache ...@@ -5,9 +5,9 @@ module Cache
# A cache store implementation which stores everything into memory in the # A cache store implementation which stores everything into memory in the
# same process. If you're running multiple Ruby on Rails server processes # same process. If you're running multiple Ruby on Rails server processes
# (which is the case if you're using mongrel_cluster or Phusion Passenger), # (which is the case if you're using mongrel_cluster or Phusion Passenger),
# then this means that your Rails server process instances won't be able # then this means that Rails server process instances won't be able
# to share cache data with each other and this may not be the most # to share cache data with each other and this may not be the most
# appropriate cache for you. # appropriate cache in that scenario.
# #
# This cache has a bounded size specified by the :size options to the # This cache has a bounded size specified by the :size options to the
# initializer (default is 32Mb). When the cache exceeds the allotted size, # initializer (default is 32Mb). When the cache exceeds the allotted size,
...@@ -47,8 +47,8 @@ def cleanup(options = nil) ...@@ -47,8 +47,8 @@ def cleanup(options = nil)
end end
end end
# Prune the cache down so the entries fit within the specified memory size by removing # To ensure entries fit within the specified memory prune the cache by removing the least
# the least recently accessed entries. # recently accessed entries.
def prune(target_size, max_time = nil) def prune(target_size, max_time = nil)
return if pruning? return if pruning?
@pruning = true @pruning = true
...@@ -67,7 +67,7 @@ def prune(target_size, max_time = nil) ...@@ -67,7 +67,7 @@ def prune(target_size, max_time = nil)
end end
end end
# Return true if the cache is currently be pruned to remove older entries. # Returns true if the cache is currently being pruned.
def pruning? def pruning?
@pruning @pruning
end end
......
...@@ -8,7 +8,7 @@ module Strategy ...@@ -8,7 +8,7 @@ module Strategy
# duration of a block. Repeated calls to the cache for the same key will hit the # duration of a block. Repeated calls to the cache for the same key will hit the
# in memory cache for faster access. # in memory cache for faster access.
module LocalCache module LocalCache
# Simple memory backed cache. This cache is not thread safe but is intended only # Simple memory backed cache. This cache is not thread safe and is intended only
# for serving as a temporary memory cache for a single thread. # for serving as a temporary memory cache for a single thread.
class LocalStore < Store class LocalStore < Store
def initialize def initialize
...@@ -16,7 +16,7 @@ def initialize ...@@ -16,7 +16,7 @@ def initialize
@data = {} @data = {}
end end
# Since it isn't thread safe, don't allow synchronizing. # Don't allow synchronizing since it isn't thread safe,
def synchronize # :nodoc: def synchronize # :nodoc:
yield yield
end end
...@@ -39,7 +39,7 @@ def delete_entry(key, options) ...@@ -39,7 +39,7 @@ def delete_entry(key, options)
end end
end end
# Use a local cache to front for the cache for the duration of a block. # Use a local cache for the duration of block.
def with_local_cache def with_local_cache
save_val = Thread.current[thread_local_key] save_val = Thread.current[thread_local_key]
begin begin
...@@ -50,8 +50,8 @@ def with_local_cache ...@@ -50,8 +50,8 @@ def with_local_cache
end end
end end
# Middleware class can be inserted as a Rack handler to use a local cache for the # Middleware class can be inserted as a Rack handler to be local cache for the
# duration of a request. # duration of request.
def middleware def middleware
@middleware ||= begin @middleware ||= begin
klass = Class.new klass = Class.new
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册