cachetastic 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/doc/classes/ActiveRecord/Base.html +188 -0
- data/doc/classes/CGI/Session/CachetasticStore.html +124 -0
- data/doc/classes/Cachetastic/Adapters/Base.html +331 -0
- data/doc/classes/Cachetastic/Adapters/Drb.html +332 -0
- data/doc/classes/Cachetastic/Adapters/File.html +248 -0
- data/doc/classes/Cachetastic/Adapters/FileBase.html +309 -0
- data/doc/classes/Cachetastic/Adapters/HtmlFile.html +224 -0
- data/doc/classes/Cachetastic/Adapters/LocalMemory.html +346 -0
- data/doc/classes/Cachetastic/Adapters/Memcache.html +498 -0
- data/doc/classes/Cachetastic/Cacheable.html +264 -0
- data/doc/classes/Cachetastic/Cacheable/ClassAndInstanceMethods.html +287 -0
- data/doc/classes/Cachetastic/Cacheable/ClassOnlyMethods.html +200 -0
- data/doc/classes/Cachetastic/Caches/Base.html +672 -0
- data/doc/classes/Cachetastic/Caches/Base/RegisteredCaches.html +179 -0
- data/doc/classes/Cachetastic/Caches/MackSessionCache.html +119 -0
- data/doc/classes/Cachetastic/Caches/PageCache.html +121 -0
- data/doc/classes/Cachetastic/Caches/RailsSessionCache.html +154 -0
- data/doc/classes/Cachetastic/Connection.html +212 -0
- data/doc/classes/Cachetastic/Errors/UnsupportedAdapter.html +146 -0
- data/doc/classes/Cachetastic/Logger.html +189 -0
- data/doc/classes/Object.html +152 -0
- data/doc/created.rid +1 -0
- data/doc/files/README.html +207 -0
- data/doc/files/lib/adapters/cachetastic_adapters_base_rb.html +139 -0
- data/doc/files/lib/adapters/cachetastic_adapters_drb_rb.html +115 -0
- data/doc/files/lib/adapters/cachetastic_adapters_file_base_rb.html +109 -0
- data/doc/files/lib/adapters/cachetastic_adapters_file_rb.html +121 -0
- data/doc/files/lib/adapters/cachetastic_adapters_html_file_rb.html +137 -0
- data/doc/files/lib/adapters/cachetastic_adapters_local_memory_rb.html +109 -0
- data/doc/files/lib/adapters/cachetastic_adapters_memcache_rb.html +127 -0
- data/doc/files/lib/adapters/cachetastic_adapters_store_object_rb.html +101 -0
- data/doc/files/lib/caches/cachetastic_caches_base_rb.html +108 -0
- data/doc/files/lib/caches/cachetastic_caches_mack_session_cache_rb.html +107 -0
- data/doc/files/lib/caches/cachetastic_caches_page_cache_rb.html +109 -0
- data/doc/files/lib/caches/cachetastic_caches_rails_session_cache_rb.html +107 -0
- data/doc/files/lib/cachetastic_cacheable_rb.html +101 -0
- data/doc/files/lib/cachetastic_connection_rb.html +107 -0
- data/doc/files/lib/cachetastic_logger_rb.html +107 -0
- data/doc/files/lib/cachetastic_rb.html +222 -0
- data/doc/files/lib/errors/cachetastic_errors_unsupported_adapter_rb.html +101 -0
- data/doc/files/lib/rails_extensions/cachetastic_active_record_base_rb.html +101 -0
- data/doc/files/lib/rails_extensions/cgi_session_cachetastic_store_rb.html +109 -0
- data/doc/files/lib/ruby_extensions/object_rb.html +101 -0
- data/doc/fr_class_index.html +47 -0
- data/doc/fr_file_index.html +47 -0
- data/doc/fr_method_index.html +100 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/cachetastic.rb +21 -23
- data/lib/cachetastic_cacheable.rb +202 -0
- data/lib/rails_extensions/cachetastic_active_record_base.rb +12 -39
- data/lib/ruby_extensions/object.rb +8 -0
- data/test/active_record_test.rb +8 -8
- data/test/cacheable_test.rb +72 -0
- metadata +52 -2
- data/lib/helpers/cachetastic_helpers_active_record.rb +0 -46
@@ -1,46 +0,0 @@
|
|
1
|
-
module Cachetastic
|
2
|
-
module Helpers
|
3
|
-
# These helpers get added to ActiveRecord at both class and instance levels.
|
4
|
-
module ActiveRecord
|
5
|
-
|
6
|
-
# Returns the Cachetastic::Caches::Base object associated with the ActiveRecord model.
|
7
|
-
# If a cache hasn't been defined the one will be created on the fly.
|
8
|
-
# The cache for the ActiveRecord model is expected to be defined as:
|
9
|
-
# Cachetastic::Caches::ActiveRecord::MODEL_NAME_HERE
|
10
|
-
def cache_class
|
11
|
-
n = self.class.name
|
12
|
-
n = self.name if n == "Class"
|
13
|
-
# puts "n: #{n}"
|
14
|
-
c_name = "Cachetastic::Caches::ActiveRecord::#{n}Cache"
|
15
|
-
unless Cachetastic::Caches::ActiveRecord.const_defined?("#{n}Cache")
|
16
|
-
# puts "we need to create a cache for: #{c_name}"
|
17
|
-
eval %{
|
18
|
-
class #{c_name} < Cachetastic::Caches::Base
|
19
|
-
end
|
20
|
-
}
|
21
|
-
end
|
22
|
-
c_name.constantize
|
23
|
-
end
|
24
|
-
|
25
|
-
# How much did I want to call this method cache?? It originally was that, but
|
26
|
-
# in Rails 2.0 they decided to use that name, so I had to rename this method.
|
27
|
-
# This method will attempt to get an object from the cache for a given key.
|
28
|
-
# If the object is nil and a block is given the block will be run, and the results
|
29
|
-
# of the block will be automatically cached.
|
30
|
-
def cacher(key, expiry = 0)
|
31
|
-
cache_class.get(key) do
|
32
|
-
if block_given?
|
33
|
-
res = yield
|
34
|
-
cache_class.set(key, res, expiry)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# Expires all the objects associated with this ActiveRecord model's cache.
|
40
|
-
def expire_all
|
41
|
-
cache_class.expire_all
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|