Skip to content

Commit 1d23ae6

Browse files
committed
tagging example
1 parent 9e4efed commit 1d23ae6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

actionpack/lib/action_controller/caching/fragments.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@ module Fragments
1818
# a key suitable for use in reading, writing, or expiring a
1919
# cached fragment. All keys are prefixed with <tt>views/</tt> and uses
2020
# ActiveSupport::Cache.expand_cache_key for the expansion.
21+
#
22+
# @param [Hash, #cache_key, Array, #to_a, #to_param] key
23+
# @return [String]
2124
def fragment_cache_key(key)
2225
ActiveSupport::Cache.expand_cache_key(key.is_a?(Hash) ? url_for(key).split("://").last : key, :views)
2326
end
2427

2528
# Writes +content+ to the location signified by
2629
# +key+ (see +expire_fragment+ for acceptable formats).
30+
#
31+
# @param [Hash, #cache_key, Array, #to_a, #to_param] key
32+
# @param [#to_str] content
33+
# @param [Hash, nil] options
34+
# @return [String]
2735
def write_fragment(key, content, options = nil)
2836
return content unless cache_configured?
2937

@@ -37,6 +45,10 @@ def write_fragment(key, content, options = nil)
3745

3846
# Reads a cached fragment from the location signified by +key+
3947
# (see +expire_fragment+ for acceptable formats).
48+
#
49+
# @param [Hash, #cache_key, Array, #to_a, #to_param] key
50+
# @param [Hash, nil] options
51+
# @return [String, nil]
4052
def read_fragment(key, options = nil)
4153
return unless cache_configured?
4254

@@ -49,6 +61,10 @@ def read_fragment(key, options = nil)
4961

5062
# Check if a cached fragment from the location signified by
5163
# +key+ exists (see +expire_fragment+ for acceptable formats).
64+
#
65+
# @param [Hash, #cache_key, Array, #to_a, #to_param] key
66+
# @param [Hash, nil] options
67+
# @return [Boolean]
5268
def fragment_exist?(key, options = nil)
5369
return unless cache_configured?
5470
key = fragment_cache_key(key)
@@ -76,6 +92,10 @@ def fragment_exist?(key, options = nil)
7692
#
7793
# +options+ is passed through to the cache store's +delete+
7894
# method (or <tt>delete_matched</tt>, for Regexp keys).
95+
#
96+
# @param [Hash, #cache_key, Array, #to_a, #to_param] key
97+
# @param [Hash, nil] options
98+
# @return [void]
7999
def expire_fragment(key, options = nil)
80100
return unless cache_configured?
81101
key = fragment_cache_key(key) unless key.is_a?(Regexp)
@@ -89,6 +109,9 @@ def expire_fragment(key, options = nil)
89109
end
90110
end
91111

112+
# @param [#to_s] name
113+
# @param [Hash, #cache_key, Array, #to_a, #to_param] key
114+
# @return [void]
92115
def instrument_fragment_cache(name, key) # :nodoc:
93116
ActiveSupport::Notifications.instrument("#{name}.action_controller", :key => key){ yield }
94117
end

0 commit comments

Comments
 (0)