public
Description: A very simple, yet very powerful caching framework for Ruby
Homepage: http://www.mackframework.com
Clone URL: git://github.com/markbates/cachetastic.git
Release 1.7.0
markbates (author)
Wed Jun 04 07:09:57 -0700 2008
commit  425002c482ea578576bc686c5805a74f2e41d747
tree    c1a9b3daa0b0ff860560e996d662537681c4ba77
parent  1a181edaa254b5a52ecbf7301be6238a2267da5e
...
8
9
10
11
 
12
13
14
...
25
26
27
28
29
30
31
32
33
...
36
37
38
39
40
 
 
41
42
43
44
45
 
46
47
48
...
8
9
10
 
11
12
13
14
...
25
26
27
 
 
 
28
29
30
...
33
34
35
 
 
36
37
38
39
40
41
 
42
43
44
45
0
@@ -8,7 +8,7 @@ require 'rubyforge'
0
 require 'rubygems'
0
 require 'rubygems/gem_runner'
0
 
0
-GEM_VERSION = "1.6.0"
0
+GEM_VERSION = "1.7.0"
0
 GEM_NAME = "cachetastic"
0
 GEM_RUBYFORGE_PROJECT = "magrathea"
0
 
0
@@ -25,9 +25,6 @@ gem_spec = Gem::Specification.new do |s|
0
 
0
   s.files = FileList['lib/**/*.rb', 'README', 'doc/**/*.*', 'bin/**/*.*']
0
   s.require_paths << 'lib'
0
-
0
- # This has been removed in RubyGems in 1.0, so I would STRONGLY recommend not using it!
0
- s.autorequire = "cachetastic"
0
 
0
   #s.bindir = "bin"
0
   #s.executables << "cachetastic"
0
@@ -36,13 +33,13 @@ gem_spec = Gem::Specification.new do |s|
0
   s.add_dependency("application_configuration")
0
   #s.add_dependency("", "")
0
   #s.extensions << ""
0
- #s.extra_rdoc_files = ["README"]
0
- #s.has_rdoc = true
0
+ s.extra_rdoc_files = ["README"]
0
+ s.has_rdoc = true
0
   #s.platform = "Gem::Platform::Ruby"
0
   #s.required_ruby_version = ">= 1.8.5"
0
   #s.requirements << "An ice cold beer."
0
   #s.requirements << "Some free time!"
0
- #s.rubyforge_project = "cachetastic"
0
+ s.rubyforge_project = "magrathea"
0
 end
0
 
0
 # rake package
...
55
56
57
58
 
59
60
61
...
55
56
57
 
58
59
60
61
0
@@ -55,7 +55,7 @@ class Cachetastic::Caches::Base
0
     # will be run. This can be used to JIT caches, just make
0
     # sure in the block to call the set method because the
0
     # results of the block are not automatically cached.
0
- def get(key)
0
+ def get(key, &block)
0
       res = nil
0
       do_with_logging(:get, key) do
0
         retryable(:on => ArgumentError) do
...
6
7
8
 
9
10
11
...
6
7
8
9
10
11
12
0
@@ -6,6 +6,7 @@ require 'yaml'
0
 require 'zlib'
0
 require 'pp'
0
 require 'drb'
0
+require 'mack_ruby_core_extensions'
0
 require 'application_configuration'
0
 begin
0
   require 'memcache'
...
1
2
3
4
5
6
7
8
...
123
124
125
126
 
127
128
129
...
147
148
149
150
 
151
152
153
...
180
181
182
183
184
185
186
187
188
...
1
2
 
 
 
3
4
5
...
120
121
122
 
123
124
125
126
...
144
145
146
 
147
148
149
150
...
177
178
179
 
 
 
180
181
182
0
@@ -1,8 +1,5 @@
0
 module Cachetastic
0
   # Include this module into an Object to achieve simplistic Object level caching.
0
- # When including this module you *MUST* create an instance level method called cachetastic_key and
0
- # have it return a valid key! If you return nil from the cachetastic_key method you will not be
0
- # able to use the cache_self and uncache_self methods.
0
   #
0
   # Example:
0
   # class Person
0
@@ -123,7 +120,7 @@ module Cachetastic
0
     # Unless the object's cachetastic_key method returns nil this method will store
0
     # the object in the cache using the object's cachetastic_key as the key.
0
     # You *MUST* create an instance level method called cachetastic_key and
0
- # have it return a valid key! If you return nil from the cachetastic_key method you will not be
0
+ # have it return a valid key! If you return nil from the cachetastic_key method or you will not be
0
     # able to use the cache_self and uncache_self methods.
0
     #
0
     # Example:
0
@@ -147,7 +144,7 @@ module Cachetastic
0
     # Unless the object's cachetastic_key method returns nil this method will delete
0
     # the object in the cache using the object's cachetastic_key as the key.
0
     # You *MUST* create an instance level method called cachetastic_key and
0
- # have it return a valid key! If you return nil from the cachetastic_key method you will not be
0
+ # have it return a valid key! If you return nil from the cachetastic_key method or you will not be
0
     # able to use the cache_self and uncache_self methods.
0
     #
0
     # Example:
0
@@ -180,9 +177,6 @@ module Cachetastic
0
     
0
     module ClassOnlyMethods
0
       # Returns an object from the cache for a given key.
0
- # If the object returned is nil and the self_populate parameter is true
0
- # then the key will be used to try and find the object in the database,
0
- # set the object into the cache, and then return the object.
0
       def get_from_cache(key, &block)
0
         cache_class.get(key, &block)
0
       end
...
6
7
8
 
 
 
 
9
10
11
...
6
7
8
9
10
11
12
13
14
15
0
@@ -6,6 +6,10 @@ class ActiveRecord::Base
0
     self.id
0
   end
0
   
0
+ # Returns an object from the cache for a given key.
0
+ # If the object returned is nil and the self_populate parameter is true
0
+ # then the key will be used to try and find the object in the database,
0
+ # set the object into the cache, and then return the object.
0
   def self.get_from_cache(key, self_populate = false)
0
     res = cache_class.get(key)
0
     if res.nil? && self_populate
...
67
68
69
 
 
 
 
70
71
72
73
...
67
68
69
70
71
72
73
74
75
76
77
0
@@ -67,6 +67,10 @@ class CacheableTest < Test::Unit::TestCase
0
   def test_get_from_cache
0
     assert_nil Person.get_from_cache("i should be nil")
0
     assert_equal 86, Person.get_from_cache("maxwell smart") {86}
0
+ x = Person.get_from_cache("my name") do |key|
0
+ "Mark Bates"
0
+ end
0
+ assert_equal "Mark Bates", x
0
   end
0
   
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.