cachetastic 1.1.3 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/README +3 -1
  2. data/doc/classes/ActiveRecord/Base.html +22 -2
  3. data/doc/classes/ActiveRecord/Base.src/M000001.html +1 -1
  4. data/doc/classes/ActiveRecord/Base.src/M000002.html +1 -1
  5. data/doc/classes/ActiveRecord/Base.src/M000003.html +1 -1
  6. data/doc/classes/ActiveRecord/Base.src/M000004.html +1 -1
  7. data/doc/classes/ActiveRecord/Base.src/M000005.html +1 -1
  8. data/doc/classes/{Cachetastic/Stores.html → CGI/Session/CachetasticStore.html} +23 -14
  9. data/doc/classes/Cachetastic/Caches/Base/RegisteredCaches.html +17 -6
  10. data/doc/classes/Cachetastic/Caches/Base/RegisteredCaches.src/{M000044.html → M000043.html} +1 -1
  11. data/doc/classes/Cachetastic/Caches/Base.html +148 -54
  12. data/doc/classes/Cachetastic/Caches/Base.src/{M000043.html → M000032.html} +4 -4
  13. data/doc/classes/Cachetastic/Caches/Base.src/M000033.html +14 -4
  14. data/doc/classes/Cachetastic/Caches/Base.src/M000034.html +9 -6
  15. data/doc/classes/Cachetastic/Caches/Base.src/M000035.html +5 -13
  16. data/doc/classes/Cachetastic/Caches/Base.src/M000036.html +5 -18
  17. data/doc/classes/Cachetastic/Caches/Base.src/M000037.html +4 -6
  18. data/doc/classes/Cachetastic/Caches/Base.src/M000038.html +4 -5
  19. data/doc/classes/Cachetastic/Caches/Base.src/M000039.html +4 -4
  20. data/doc/classes/Cachetastic/Caches/Base.src/M000040.html +4 -4
  21. data/doc/classes/Cachetastic/Caches/Base.src/M000041.html +4 -4
  22. data/doc/classes/Cachetastic/Caches/Base.src/M000042.html +14 -4
  23. data/doc/classes/Cachetastic/Caches/PageCache.html +8 -0
  24. data/doc/classes/Cachetastic/Caches/RailsSessionCache.html +6 -0
  25. data/doc/classes/Cachetastic/Connection.html +14 -14
  26. data/doc/classes/Cachetastic/Connection.src/M000044.html +18 -0
  27. data/doc/classes/Cachetastic/Connection.src/M000045.html +10 -4
  28. data/doc/classes/Cachetastic/Logger.html +5 -5
  29. data/doc/classes/Cachetastic/Stores/Base.html +68 -45
  30. data/doc/classes/Cachetastic/Stores/Base.src/{M000028.html → M000023.html} +1 -1
  31. data/doc/classes/Cachetastic/Stores/Base.src/{M000030.html → M000024.html} +1 -1
  32. data/doc/classes/Cachetastic/Stores/Base.src/{M000032.html → M000025.html} +1 -1
  33. data/doc/classes/Cachetastic/Stores/File.html +265 -0
  34. data/doc/classes/Cachetastic/Stores/File.src/M000026.html +18 -0
  35. data/doc/classes/Cachetastic/Stores/File.src/M000027.html +20 -0
  36. data/doc/classes/Cachetastic/Stores/File.src/M000028.html +19 -0
  37. data/doc/classes/Cachetastic/Stores/File.src/M000029.html +33 -0
  38. data/doc/classes/Cachetastic/Stores/File.src/M000030.html +21 -0
  39. data/doc/classes/Cachetastic/Stores/{LocalMemory.src/M000025.html → File.src/M000031.html} +3 -3
  40. data/doc/classes/Cachetastic/Stores/LocalMemory.html +41 -36
  41. data/doc/classes/Cachetastic/Stores/{Base.src/M000029.html → LocalMemory.src/M000017.html} +3 -3
  42. data/doc/classes/Cachetastic/Stores/LocalMemory.src/M000018.html +18 -0
  43. data/doc/classes/Cachetastic/Stores/LocalMemory.src/M000019.html +18 -0
  44. data/doc/classes/Cachetastic/Stores/LocalMemory.src/M000020.html +12 -4
  45. data/doc/classes/Cachetastic/Stores/LocalMemory.src/M000021.html +4 -4
  46. data/doc/classes/Cachetastic/Stores/LocalMemory.src/M000022.html +11 -4
  47. data/doc/classes/Cachetastic/Stores/Memcache.html +85 -59
  48. data/doc/classes/Cachetastic/Stores/Memcache.src/M000006.html +19 -0
  49. data/doc/classes/Cachetastic/Stores/{LocalMemory.src/M000024.html → Memcache.src/M000007.html} +3 -3
  50. data/doc/classes/Cachetastic/Stores/Memcache.src/M000008.html +18 -0
  51. data/doc/classes/Cachetastic/Stores/Memcache.src/M000009.html +4 -5
  52. data/doc/classes/Cachetastic/Stores/Memcache.src/M000010.html +4 -4
  53. data/doc/classes/Cachetastic/Stores/Memcache.src/M000011.html +4 -4
  54. data/doc/classes/Cachetastic/Stores/Memcache.src/M000012.html +10 -4
  55. data/doc/classes/Cachetastic/Stores/Memcache.src/M000013.html +5 -4
  56. data/doc/classes/Cachetastic/Stores/Memcache.src/M000014.html +6 -4
  57. data/doc/classes/Cachetastic/Stores/Memcache.src/M000015.html +6 -5
  58. data/doc/classes/Cachetastic/Stores/Memcache.src/M000016.html +9 -9
  59. data/doc/created.rid +1 -1
  60. data/doc/files/init_rb.html +111 -1
  61. data/doc/files/lib/caches/cachetastic_caches_base_rb.html +1 -1
  62. data/doc/files/lib/caches/cachetastic_caches_page_cache_rb.html +9 -1
  63. data/doc/files/lib/caches/cachetastic_caches_rails_session_cache_rb.html +7 -1
  64. data/doc/files/lib/cachetastic_connection_rb.html +1 -1
  65. data/doc/files/lib/cachetastic_rb.html +6 -2
  66. data/doc/files/lib/helpers/cachetastic_helpers_active_record_rb.html +1 -1
  67. data/doc/files/lib/rails_extensions/cachetastic_active_record_base_rb.html +1 -1
  68. data/doc/files/lib/rails_extensions/cgi_session_cachetastic_store_rb.html +1 -1
  69. data/doc/files/lib/stores/cachetastic_stores_base_rb.html +39 -1
  70. data/doc/{classes/ActiveRecord.html → files/lib/stores/cachetastic_stores_file_rb.html} +36 -22
  71. data/doc/files/lib/stores/cachetastic_stores_local_memory_rb.html +9 -1
  72. data/doc/files/lib/stores/cachetastic_stores_memcache_rb.html +27 -1
  73. data/doc/{classes/Cachetastic/Caches/ActiveRecord.html → files/lib/stores/cachetastic_stores_store_object_rb.html} +15 -19
  74. data/doc/fr_class_index.html +2 -8
  75. data/doc/fr_file_index.html +2 -0
  76. data/doc/fr_method_index.html +41 -42
  77. data/doc/index.html +2 -2
  78. data/init.rb +1 -0
  79. data/lib/caches/cachetastic_caches_base.rb +81 -18
  80. data/lib/caches/cachetastic_caches_page_cache.rb +4 -0
  81. data/lib/caches/cachetastic_caches_rails_session_cache.rb +1 -0
  82. data/lib/cachetastic.rb +10 -6
  83. data/lib/cachetastic_connection.rb +2 -2
  84. data/lib/helpers/cachetastic_helpers_active_record.rb +12 -1
  85. data/lib/rails_extensions/cachetastic_active_record_base.rb +10 -0
  86. data/lib/rails_extensions/cgi_session_cachetastic_store.rb +15 -10
  87. data/lib/stores/cachetastic_stores_base.rb +33 -13
  88. data/lib/stores/cachetastic_stores_file.rb +101 -0
  89. data/lib/stores/cachetastic_stores_local_memory.rb +6 -27
  90. data/lib/stores/cachetastic_stores_memcache.rb +24 -5
  91. data/lib/stores/cachetastic_stores_store_object.rb +28 -0
  92. data/lib/tasks/rubyforge_config.yml +1 -1
  93. metadata +28 -32
  94. data/doc/classes/Cachetastic/Caches.html +0 -114
  95. data/doc/classes/Cachetastic/Connection.src/M000046.html +0 -24
  96. data/doc/classes/Cachetastic/Helpers/ActiveRecord.html +0 -165
  97. data/doc/classes/Cachetastic/Helpers/ActiveRecord.src/M000006.html +0 -29
  98. data/doc/classes/Cachetastic/Helpers/ActiveRecord.src/M000007.html +0 -23
  99. data/doc/classes/Cachetastic/Helpers/ActiveRecord.src/M000008.html +0 -18
  100. data/doc/classes/Cachetastic/Helpers.html +0 -115
  101. data/doc/classes/Cachetastic/Stores/Base.src/M000031.html +0 -22
  102. data/doc/classes/Cachetastic/Stores/LocalMemory/StoreObject.html +0 -177
  103. data/doc/classes/Cachetastic/Stores/LocalMemory/StoreObject.src/M000026.html +0 -27
  104. data/doc/classes/Cachetastic/Stores/LocalMemory/StoreObject.src/M000027.html +0 -19
  105. data/doc/classes/Cachetastic/Stores/LocalMemory.src/M000023.html +0 -26
  106. data/doc/classes/Cachetastic/Stores/Memcache.src/M000017.html +0 -20
  107. data/doc/classes/Cachetastic/Stores/Memcache.src/M000018.html +0 -20
  108. data/doc/classes/Cachetastic/Stores/Memcache.src/M000019.html +0 -24
  109. data/doc/classes/Cachetastic.html +0 -119
  110. /data/doc/classes/Cachetastic/Logger.src/{M000047.html → M000046.html} +0 -0
data/README CHANGED
@@ -11,7 +11,7 @@
11
11
  debug: true # true | false (default: false)
12
12
  # this is the type of file store to be used for this cache.
13
13
  # more stores can be developed and plugged in as desired
14
- store: local_memory # local_memory | memcache (default: local_memory)
14
+ store: local_memory # local_memory | memcache | file (default: local_memory)
15
15
  # this will marshall objects into and out of the store.
16
16
  # so far yaml is the only supported marshall format.
17
17
  marshall_method: none # none | yaml (default: none)
@@ -29,6 +29,8 @@
29
29
  debug: false
30
30
  readonly: false
31
31
  urlencode: false
32
+ store_options: # listed below are the options for file
33
+ dir: /cachetastic/caches/ # absolute path to the directory where caches should be stored.
32
34
  # configure logging for this cache:
33
35
  logging:
34
36
  # n number of logs can be configured for a cache
@@ -102,8 +102,8 @@
102
102
  <h3 class="section-bar">Included Modules</h3>
103
103
 
104
104
  <div id="includes-list">
105
- <span class="include-name"><a href="../Cachetastic/Helpers/ActiveRecord.html">Cachetastic::Helpers::ActiveRecord</a></span>
106
- <span class="include-name"><a href="../Cachetastic/Helpers/ActiveRecord.html">Cachetastic::Helpers::ActiveRecord</a></span>
105
+ <span class="include-name">Cachetastic::Helpers::ActiveRecord</span>
106
+ <span class="include-name">Cachetastic::Helpers::ActiveRecord</span>
107
107
  </div>
108
108
  </div>
109
109
 
@@ -131,6 +131,9 @@
131
131
  </div>
132
132
 
133
133
  <div class="method-description">
134
+ <p>
135
+ Deletes an object from the cache for a given key.
136
+ </p>
134
137
  </div>
135
138
  </div>
136
139
 
@@ -145,6 +148,12 @@
145
148
  </div>
146
149
 
147
150
  <div class="method-description">
151
+ <p>
152
+ Returns an object from the cache for a given key. If the object returned is
153
+ nil and the self_populate parameter is true then the key will be used to
154
+ try and find the object in the database, set the object into the cache, and
155
+ then return the object.
156
+ </p>
148
157
  </div>
149
158
  </div>
150
159
 
@@ -159,6 +168,9 @@
159
168
  </div>
160
169
 
161
170
  <div class="method-description">
171
+ <p>
172
+ Sets an object into the cache for a given key.
173
+ </p>
162
174
  </div>
163
175
  </div>
164
176
 
@@ -175,6 +187,10 @@
175
187
  </div>
176
188
 
177
189
  <div class="method-description">
190
+ <p>
191
+ Unless the object is a new ActiveRecord object this method will store the
192
+ object in the cache using the object&#8216;s ID as the key.
193
+ </p>
178
194
  </div>
179
195
  </div>
180
196
 
@@ -189,6 +205,10 @@
189
205
  </div>
190
206
 
191
207
  <div class="method-description">
208
+ <p>
209
+ Unless the object is a new ActiveRecord object this method will delete the
210
+ object in the cache using the object&#8216;s ID as the key.
211
+ </p>
192
212
  </div>
193
213
  </div>
194
214
 
@@ -10,7 +10,7 @@
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/rails_extensions/cachetastic_active_record_base.rb, line 8</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/rails_extensions/cachetastic_active_record_base.rb, line 12</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_from_cache</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">self_populate</span> = <span class="ruby-keyword kw">false</span>)
15
15
  <span class="ruby-identifier">res</span> = <span class="ruby-identifier">cache_class</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>)
16
16
  <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">self_populate</span>
@@ -10,7 +10,7 @@
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/rails_extensions/cachetastic_active_record_base.rb, line 19</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/rails_extensions/cachetastic_active_record_base.rb, line 24</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_from_cache</span>(<span class="ruby-identifier">key</span>)
15
15
  <span class="ruby-identifier">cache_class</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
16
16
  <span class="ruby-keyword kw">end</span></pre>
@@ -10,7 +10,7 @@
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/rails_extensions/cachetastic_active_record_base.rb, line 23</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/rails_extensions/cachetastic_active_record_base.rb, line 29</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_into_cache</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">expiry</span> = <span class="ruby-value">0</span>)
15
15
  <span class="ruby-identifier">cache_class</span>.<span class="ruby-identifier">set</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">expiry</span>)
16
16
  <span class="ruby-keyword kw">end</span></pre>
@@ -10,7 +10,7 @@
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/rails_extensions/cachetastic_active_record_base.rb, line 29</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/rails_extensions/cachetastic_active_record_base.rb, line 37</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cache_self</span>
15
15
  <span class="ruby-identifier">cache_class</span>.<span class="ruby-identifier">set</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">id</span>, <span class="ruby-keyword kw">self</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new_record?</span>
16
16
  <span class="ruby-keyword kw">end</span></pre>
@@ -10,7 +10,7 @@
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/rails_extensions/cachetastic_active_record_base.rb, line 33</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/rails_extensions/cachetastic_active_record_base.rb, line 43</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uncache_self</span>
15
15
  <span class="ruby-identifier">cache_class</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">id</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new_record?</span>
16
16
  <span class="ruby-keyword kw">end</span></pre>
@@ -5,10 +5,10 @@
5
5
 
6
6
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
7
  <head>
8
- <title>Module: Cachetastic::Stores</title>
8
+ <title>Class: CGI::Session::CachetasticStore</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
10
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
12
  <script type="text/javascript">
13
13
  // <![CDATA[
14
14
 
@@ -49,19 +49,25 @@
49
49
  <div id="classHeader">
50
50
  <table class="header-table">
51
51
  <tr class="top-aligned-row">
52
- <td><strong>Module</strong></td>
53
- <td class="class-name-in-header">Cachetastic::Stores</td>
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">CGI::Session::CachetasticStore</td>
54
54
  </tr>
55
55
  <tr class="top-aligned-row">
56
56
  <td><strong>In:</strong></td>
57
57
  <td>
58
- <a href="../../files/lib/cachetastic_rb.html">
59
- lib/cachetastic.rb
58
+ <a href="../../../files/lib/rails_extensions/cgi_session_cachetastic_store_rb.html">
59
+ lib/rails_extensions/cgi_session_cachetastic_store.rb
60
60
  </a>
61
61
  <br />
62
62
  </td>
63
63
  </tr>
64
64
 
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
65
71
  </table>
66
72
  </div>
67
73
  <!-- banner header -->
@@ -72,6 +78,17 @@
72
78
 
73
79
  <div id="contextContent">
74
80
 
81
+ <div id="description">
82
+ <p>
83
+ Allows Rails to use Cachetastic for it&#8216;s session store. The setting
84
+ below needs to happen AFTER the gem has been required, obviously! In Rails
85
+ 1.2.6 this is AFTER the initializer block.
86
+ </p>
87
+ <pre>
88
+ ActionController::Base.session_store = :cachetastic_store
89
+ </pre>
90
+
91
+ </div>
75
92
 
76
93
 
77
94
  </div>
@@ -84,14 +101,6 @@
84
101
 
85
102
  <div id="section">
86
103
 
87
- <div id="class-list">
88
- <h3 class="section-bar">Classes and Modules</h3>
89
-
90
- Class <a href="Stores/Base.html" class="link">Cachetastic::Stores::Base</a><br />
91
- Class <a href="Stores/LocalMemory.html" class="link">Cachetastic::Stores::LocalMemory</a><br />
92
- Class <a href="Stores/Memcache.html" class="link">Cachetastic::Stores::Memcache</a><br />
93
-
94
- </div>
95
104
 
96
105
 
97
106
 
@@ -78,6 +78,14 @@
78
78
 
79
79
  <div id="contextContent">
80
80
 
81
+ <div id="description">
82
+ <p>
83
+ Used to store a list of all the caches registered with the system. In order
84
+ for a cache to be registered it must extend <a
85
+ href="../Base.html">Cachetastic::Caches::Base</a>.
86
+ </p>
87
+
88
+ </div>
81
89
 
82
90
 
83
91
  </div>
@@ -86,7 +94,7 @@
86
94
  <h3 class="section-bar">Methods</h3>
87
95
 
88
96
  <div class="name-list">
89
- <a href="#M000044">new</a>&nbsp;&nbsp;
97
+ <a href="#M000043">new</a>&nbsp;&nbsp;
90
98
  </div>
91
99
  </div>
92
100
 
@@ -116,7 +124,10 @@
116
124
  <tr class="top-aligned-row context-row">
117
125
  <td class="context-item-name">list</td>
118
126
  <td class="context-item-value">&nbsp;[R]&nbsp;</td>
119
- <td class="context-item-desc"></td>
127
+ <td class="context-item-desc">
128
+ list of all caches registered with the system.
129
+
130
+ </td>
120
131
  </tr>
121
132
  </table>
122
133
  </div>
@@ -128,12 +139,12 @@
128
139
  <div id="methods">
129
140
  <h3 class="section-bar">Public Class methods</h3>
130
141
 
131
- <div id="method-M000044" class="method-detail">
132
- <a name="M000044"></a>
142
+ <div id="method-M000043" class="method-detail">
143
+ <a name="M000043"></a>
133
144
 
134
145
  <div class="method-heading">
135
- <a href="RegisteredCaches.src/M000044.html" target="Code" class="method-signature"
136
- onclick="popupCode('RegisteredCaches.src/M000044.html');return false;">
146
+ <a href="RegisteredCaches.src/M000043.html" target="Code" class="method-signature"
147
+ onclick="popupCode('RegisteredCaches.src/M000043.html');return false;">
137
148
  <span class="method-name">new</span><span class="method-args">()</span>
138
149
  </a>
139
150
  </div>
@@ -10,7 +10,7 @@
10
10
  <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/caches/cachetastic_caches_base.rb, line 9</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/caches/cachetastic_caches_base.rb, line 37</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
15
15
  <span class="ruby-ivar">@list</span> = []
16
16
  <span class="ruby-keyword kw">end</span></pre>
@@ -78,6 +78,38 @@
78
78
 
79
79
  <div id="contextContent">
80
80
 
81
+ <div id="description">
82
+ <p>
83
+ When creating a new &#8216;Cache&#8217; this class should be extended. Once
84
+ extended you&#8216;ll only need to override just the methods that are
85
+ different for your cache.
86
+ </p>
87
+ <pre>
88
+ class MyAwesomeCache &lt; Cachetastic::Caches::Base
89
+ end
90
+ MyAwesomeCache.set(1, &quot;One&quot;)
91
+ MyAwesomeCache.get(1) # =&gt; &quot;One&quot;
92
+ MyAwesomeCache.update(1, &quot;One!!&quot;)
93
+ MyAwesomeCache.get(1) # =&gt; &quot;One!!&quot;
94
+ MyAwesomeCache.delete(1)
95
+ MyAwesomeCache.get(1) # =&gt; nil
96
+
97
+ class MyAwesomeCache &lt; Cachetastic::Caches::Base
98
+ class &lt;&lt; self
99
+ def get(key)
100
+ super(key) do
101
+ set(key, key * 10)
102
+ end
103
+ end
104
+ end
105
+ end
106
+ MyAwesomeCache.set(1, &quot;One&quot;)
107
+ MyAwesomeCache.get(1) # =&gt; &quot;One&quot;
108
+ MyAwesomeCache.delete(1)
109
+ MyAwesomeCache.get(1) # =&gt; 10
110
+ </pre>
111
+
112
+ </div>
81
113
 
82
114
 
83
115
  </div>
@@ -86,17 +118,17 @@
86
118
  <h3 class="section-bar">Methods</h3>
87
119
 
88
120
  <div class="name-list">
89
- <a href="#M000033">all_registered_caches</a>&nbsp;&nbsp;
90
- <a href="#M000041">cache_name</a>&nbsp;&nbsp;
91
- <a href="#M000037">delete</a>&nbsp;&nbsp;
92
- <a href="#M000038">expire_all</a>&nbsp;&nbsp;
93
- <a href="#M000035">get</a>&nbsp;&nbsp;
94
- <a href="#M000034">inherited</a>&nbsp;&nbsp;
95
- <a href="#M000043">logger</a>&nbsp;&nbsp;
96
- <a href="#M000039">populate_all</a>&nbsp;&nbsp;
97
- <a href="#M000036">set</a>&nbsp;&nbsp;
98
- <a href="#M000040">stats</a>&nbsp;&nbsp;
99
- <a href="#M000042">store</a>&nbsp;&nbsp;
121
+ <a href="#M000032">all_registered_caches</a>&nbsp;&nbsp;
122
+ <a href="#M000039">cache_name</a>&nbsp;&nbsp;
123
+ <a href="#M000042">calculate_expiry_time</a>&nbsp;&nbsp;
124
+ <a href="#M000035">delete</a>&nbsp;&nbsp;
125
+ <a href="#M000036">expire_all</a>&nbsp;&nbsp;
126
+ <a href="#M000033">get</a>&nbsp;&nbsp;
127
+ <a href="#M000041">logger</a>&nbsp;&nbsp;
128
+ <a href="#M000037">populate_all</a>&nbsp;&nbsp;
129
+ <a href="#M000034">set</a>&nbsp;&nbsp;
130
+ <a href="#M000038">stats</a>&nbsp;&nbsp;
131
+ <a href="#M000040">store</a>&nbsp;&nbsp;
100
132
  </div>
101
133
  </div>
102
134
 
@@ -137,129 +169,180 @@
137
169
  <div id="methods">
138
170
  <h3 class="section-bar">Public Class methods</h3>
139
171
 
140
- <div id="method-M000033" class="method-detail">
141
- <a name="M000033"></a>
172
+ <div id="method-M000032" class="method-detail">
173
+ <a name="M000032"></a>
142
174
 
143
175
  <div class="method-heading">
144
- <a href="Base.src/M000033.html" target="Code" class="method-signature"
145
- onclick="popupCode('Base.src/M000033.html');return false;">
176
+ <a href="Base.src/M000032.html" target="Code" class="method-signature"
177
+ onclick="popupCode('Base.src/M000032.html');return false;">
146
178
  <span class="method-name">all_registered_caches</span><span class="method-args">()</span>
147
179
  </a>
148
180
  </div>
149
181
 
150
182
  <div class="method-description">
183
+ <p>
184
+ Returns a list of all registered caches in the system.
185
+ </p>
151
186
  </div>
152
187
  </div>
153
188
 
154
- <div id="method-M000041" class="method-detail">
155
- <a name="M000041"></a>
189
+ <div id="method-M000039" class="method-detail">
190
+ <a name="M000039"></a>
156
191
 
157
192
  <div class="method-heading">
158
- <a href="Base.src/M000041.html" target="Code" class="method-signature"
159
- onclick="popupCode('Base.src/M000041.html');return false;">
193
+ <a href="Base.src/M000039.html" target="Code" class="method-signature"
194
+ onclick="popupCode('Base.src/M000039.html');return false;">
160
195
  <span class="method-name">cache_name</span><span class="method-args">()</span>
161
196
  </a>
162
197
  </div>
163
198
 
164
199
  <div class="method-description">
200
+ <p>
201
+ Returns a &#8216;methodize&#8217; version of the cache&#8216;s class name.
202
+ This gets used in logging, namespacing, and as the key in the <a
203
+ href="../Connection.html">Cachetastic::Connection</a> class.
204
+ </p>
205
+ <pre>
206
+ MyAwesomeCache.cache # =&gt; &quot;my_awesome_cache&quot;
207
+ Cachetastic::Caches::Base # =&gt; &quot;cachetastic_caches_base&quot;
208
+ </pre>
165
209
  </div>
166
210
  </div>
167
211
 
168
- <div id="method-M000037" class="method-detail">
169
- <a name="M000037"></a>
212
+ <div id="method-M000035" class="method-detail">
213
+ <a name="M000035"></a>
170
214
 
171
215
  <div class="method-heading">
172
- <a href="Base.src/M000037.html" target="Code" class="method-signature"
173
- onclick="popupCode('Base.src/M000037.html');return false;">
216
+ <a href="Base.src/M000035.html" target="Code" class="method-signature"
217
+ onclick="popupCode('Base.src/M000035.html');return false;">
174
218
  <span class="method-name">delete</span><span class="method-args">(key, delay = 0)</span>
175
219
  </a>
176
220
  </div>
177
221
 
178
222
  <div class="method-description">
223
+ <p>
224
+ Deletes an object from the cache. The optional delay parameter sets an
225
+ offset, in seconds, for when the object should <a
226
+ href="Base.html#M000033">get</a> deleted. The default of 0 means the object
227
+ gets deleted right away.
228
+ </p>
179
229
  </div>
180
230
  </div>
181
231
 
182
- <div id="method-M000038" class="method-detail">
183
- <a name="M000038"></a>
232
+ <div id="method-M000036" class="method-detail">
233
+ <a name="M000036"></a>
184
234
 
185
235
  <div class="method-heading">
186
- <a href="Base.src/M000038.html" target="Code" class="method-signature"
187
- onclick="popupCode('Base.src/M000038.html');return false;">
236
+ <a href="Base.src/M000036.html" target="Code" class="method-signature"
237
+ onclick="popupCode('Base.src/M000036.html');return false;">
188
238
  <span class="method-name">expire_all</span><span class="method-args">()</span>
189
239
  </a>
190
240
  </div>
191
241
 
192
242
  <div class="method-description">
243
+ <p>
244
+ Expires all objects for this cache.
245
+ </p>
193
246
  </div>
194
247
  </div>
195
248
 
196
- <div id="method-M000035" class="method-detail">
197
- <a name="M000035"></a>
249
+ <div id="method-M000033" class="method-detail">
250
+ <a name="M000033"></a>
198
251
 
199
252
  <div class="method-heading">
200
- <a href="Base.src/M000035.html" target="Code" class="method-signature"
201
- onclick="popupCode('Base.src/M000035.html');return false;">
202
- <span class="method-name">get</span><span class="method-args">(key) {|if block_given?| ...}</span>
253
+ <a href="Base.src/M000033.html" target="Code" class="method-signature"
254
+ onclick="popupCode('Base.src/M000033.html');return false;">
255
+ <span class="method-name">get</span><span class="method-args">(key) {|key if block_given?| ...}</span>
203
256
  </a>
204
257
  </div>
205
258
 
206
259
  <div class="method-description">
260
+ <p>
261
+ Returns an object from the cache for a given key. If the object comes back
262
+ as nil and a block is given that block will be run and the results of the
263
+ block will be run. This can be used to JIT caches, just make sure in the
264
+ block to call the <a href="Base.html#M000034">set</a> method because the
265
+ results of the block are not automatically cached.
266
+ </p>
207
267
  </div>
208
268
  </div>
209
269
 
210
- <div id="method-M000034" class="method-detail">
211
- <a name="M000034"></a>
270
+ <div id="method-M000041" class="method-detail">
271
+ <a name="M000041"></a>
212
272
 
213
273
  <div class="method-heading">
214
- <a href="Base.src/M000034.html" target="Code" class="method-signature"
215
- onclick="popupCode('Base.src/M000034.html');return false;">
216
- <span class="method-name">inherited</span><span class="method-args">(child)</span>
274
+ <a href="Base.src/M000041.html" target="Code" class="method-signature"
275
+ onclick="popupCode('Base.src/M000041.html');return false;">
276
+ <span class="method-name">logger</span><span class="method-args">()</span>
217
277
  </a>
218
278
  </div>
219
279
 
220
280
  <div class="method-description">
281
+ <p>
282
+ Returns the <a href="../Logger.html">Cachetastic::Logger</a> for the
283
+ underlying <a href="../Stores/Base.html">Cachetastic::Stores::Base</a>.
284
+ </p>
221
285
  </div>
222
286
  </div>
223
287
 
224
- <div id="method-M000043" class="method-detail">
225
- <a name="M000043"></a>
288
+ <div id="method-M000037" class="method-detail">
289
+ <a name="M000037"></a>
226
290
 
227
291
  <div class="method-heading">
228
- <a href="Base.src/M000043.html" target="Code" class="method-signature"
229
- onclick="popupCode('Base.src/M000043.html');return false;">
230
- <span class="method-name">logger</span><span class="method-args">()</span>
292
+ <a href="Base.src/M000037.html" target="Code" class="method-signature"
293
+ onclick="popupCode('Base.src/M000037.html');return false;">
294
+ <span class="method-name">populate_all</span><span class="method-args">()</span>
231
295
  </a>
232
296
  </div>
233
297
 
234
298
  <div class="method-description">
299
+ <p>
300
+ Raises a MethodNotImplemented exception. This method should be overridden
301
+ in the child class to enable a populating the cache with all things that
302
+ should be in there.
303
+ </p>
235
304
  </div>
236
305
  </div>
237
306
 
238
- <div id="method-M000039" class="method-detail">
239
- <a name="M000039"></a>
307
+ <div id="method-M000034" class="method-detail">
308
+ <a name="M000034"></a>
240
309
 
241
310
  <div class="method-heading">
242
- <a href="Base.src/M000039.html" target="Code" class="method-signature"
243
- onclick="popupCode('Base.src/M000039.html');return false;">
244
- <span class="method-name">populate_all</span><span class="method-args">()</span>
311
+ <a href="Base.src/M000034.html" target="Code" class="method-signature"
312
+ onclick="popupCode('Base.src/M000034.html');return false;">
313
+ <span class="method-name">set</span><span class="method-args">(key, value, expiry = (store.all_options[&quot;default_expiry&quot;] || 0))</span>
245
314
  </a>
246
315
  </div>
247
316
 
248
317
  <div class="method-description">
318
+ <p>
319
+ Set a particular object info the cache for the given key. An optional third
320
+ parameter sets the expiry time for the object in the cache. The default for
321
+ this expiry is <a href="Base.html#M000034">set</a> as either 0, meaning it
322
+ never expires, or if there&#8216;s a default_expiry time <a
323
+ href="Base.html#M000034">set</a> in the config file, that file will be
324
+ used. If there is an expiry_swing <a href="Base.html#M000034">set</a> in
325
+ the config file it will be +/- to the expiry time. See also: <a
326
+ href="Base.html#M000042">calculate_expiry_time</a>
327
+ </p>
249
328
  </div>
250
329
  </div>
251
330
 
252
- <div id="method-M000036" class="method-detail">
253
- <a name="M000036"></a>
331
+ <div id="method-M000038" class="method-detail">
332
+ <a name="M000038"></a>
254
333
 
255
334
  <div class="method-heading">
256
- <a href="Base.src/M000036.html" target="Code" class="method-signature"
257
- onclick="popupCode('Base.src/M000036.html');return false;">
258
- <span class="method-name">set</span><span class="method-args">(key, value, expiry = (store.all_options[&quot;default_expiry&quot;] || 0))</span>
335
+ <a href="Base.src/M000038.html" target="Code" class="method-signature"
336
+ onclick="popupCode('Base.src/M000038.html');return false;">
337
+ <span class="method-name">stats</span><span class="method-args">()</span>
259
338
  </a>
260
339
  </div>
261
340
 
262
341
  <div class="method-description">
342
+ <p>
343
+ A convenience method that returns statistics for the underlying <a
344
+ href="../Stores/Base.html">Cachetastic::Stores::Base</a> for the cache.
345
+ </p>
263
346
  </div>
264
347
  </div>
265
348
 
@@ -269,25 +352,36 @@
269
352
  <div class="method-heading">
270
353
  <a href="Base.src/M000040.html" target="Code" class="method-signature"
271
354
  onclick="popupCode('Base.src/M000040.html');return false;">
272
- <span class="method-name">stats</span><span class="method-args">()</span>
355
+ <span class="method-name">store</span><span class="method-args">()</span>
273
356
  </a>
274
357
  </div>
275
358
 
276
359
  <div class="method-description">
360
+ <p>
361
+ Returns the underlying <a
362
+ href="../Stores/Base.html">Cachetastic::Stores::Base</a> for this cache.
363
+ </p>
277
364
  </div>
278
365
  </div>
279
366
 
367
+ <h3 class="section-bar">Private Class methods</h3>
368
+
280
369
  <div id="method-M000042" class="method-detail">
281
370
  <a name="M000042"></a>
282
371
 
283
372
  <div class="method-heading">
284
373
  <a href="Base.src/M000042.html" target="Code" class="method-signature"
285
374
  onclick="popupCode('Base.src/M000042.html');return false;">
286
- <span class="method-name">store</span><span class="method-args">()</span>
375
+ <span class="method-name">calculate_expiry_time</span><span class="method-args">(expiry)</span>
287
376
  </a>
288
377
  </div>
289
378
 
290
379
  <div class="method-description">
380
+ <p>
381
+ If the expiry time is <a href="Base.html#M000034">set</a> to 60 minutes and
382
+ the expiry_swing time is <a href="Base.html#M000034">set</a> to 15 minutes,
383
+ this method will return a number between 45 minutes and 75 minutes.
384
+ </p>
291
385
  </div>
292
386
  </div>
293
387
 
@@ -5,14 +5,14 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>logger (Cachetastic::Caches::Base)</title>
8
+ <title>all_registered_caches (Cachetastic::Caches::Base)</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
10
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/caches/cachetastic_caches_base.rb, line 90</span>
14
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logger</span>
15
- <span class="ruby-identifier">store</span>.<span class="ruby-identifier">logger</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/caches/cachetastic_caches_base.rb, line 48</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">all_registered_caches</span>
15
+ <span class="ruby-constant">RegisteredCaches</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">list</span>
16
16
  <span class="ruby-keyword kw">end</span></pre>
17
17
  </body>
18
18
  </html>