cachetastic 2.1.4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -0
- data/README +57 -43
- data/doc/classes/Cachetastic/Adapters.html +180 -0
- data/doc/classes/Cachetastic/Adapters/Base.html +206 -123
- data/doc/classes/Cachetastic/Adapters/File.html +17 -130
- data/doc/classes/Cachetastic/Adapters/LocalMemory.html +7 -228
- data/doc/classes/Cachetastic/Adapters/Memcached.html +193 -0
- data/doc/classes/Cachetastic/Cache.html +425 -0
- data/doc/classes/Cachetastic/Cacheable.html +26 -30
- data/doc/classes/Cachetastic/Cacheable/ClassAndInstanceMethods.html +66 -62
- data/doc/classes/Cachetastic/Cacheable/ClassOnlyMethods.html +30 -30
- data/doc/classes/Cachetastic/Logger.html +31 -33
- data/doc/created.rid +1 -1
- data/doc/files/{lib/cachetastic/adapters/html_file_rb.html → LICENSE.html} +29 -34
- data/doc/files/README.html +91 -57
- data/doc/files/lib/cachetastic/adapters/base_rb.html +1 -39
- data/doc/files/lib/cachetastic/adapters/file_rb.html +1 -21
- data/doc/files/lib/cachetastic/adapters/local_memory_rb.html +1 -9
- data/doc/files/lib/cachetastic/{ruby_extensions/kernel_rb.html → adapters/memcached_rb.html} +4 -4
- data/doc/files/lib/cachetastic/{ruby_extensions/string_rb.html → cache_rb.html} +5 -5
- data/doc/files/lib/cachetastic/cacheable_rb.html +1 -1
- data/doc/files/lib/cachetastic/{caches/base_rb.html → extensions/string_rb.html} +5 -5
- data/doc/files/lib/cachetastic/logger_rb.html +1 -7
- data/doc/files/lib/cachetastic/{adapters/store_object_rb.html → store_object_rb.html} +3 -3
- data/doc/files/lib/cachetastic_rb.html +4 -95
- data/doc/fr_class_index.html +3 -15
- data/doc/fr_file_index.html +5 -16
- data/doc/fr_method_index.html +26 -78
- data/lib/cachetastic.rb +16 -70
- data/lib/cachetastic/adapters/base.rb +178 -76
- data/lib/cachetastic/adapters/file.rb +63 -46
- data/lib/cachetastic/adapters/local_memory.rb +36 -67
- data/lib/cachetastic/adapters/memcached.rb +114 -0
- data/lib/cachetastic/cache.rb +165 -0
- data/lib/cachetastic/cacheable.rb +19 -15
- data/lib/cachetastic/extensions/string.rb +8 -0
- data/lib/cachetastic/logger.rb +41 -41
- data/lib/cachetastic/store_object.rb +22 -0
- metadata +43 -64
- data/bin/cachetastic_drb_server +0 -115
- data/doc/classes/ActiveRecord/Base.html +0 -194
- data/doc/classes/CGI/Session/CachetasticStore.html +0 -124
- data/doc/classes/Cachetastic/Adapters/Drb.html +0 -332
- data/doc/classes/Cachetastic/Adapters/FileBase.html +0 -309
- data/doc/classes/Cachetastic/Adapters/HtmlFile.html +0 -224
- data/doc/classes/Cachetastic/Adapters/Memcache.html +0 -498
- data/doc/classes/Cachetastic/Caches/Base.html +0 -643
- data/doc/classes/Cachetastic/Caches/Base/RegisteredCaches.html +0 -179
- data/doc/classes/Cachetastic/Caches/MackSessionCache.html +0 -119
- data/doc/classes/Cachetastic/Caches/PageCache.html +0 -121
- data/doc/classes/Cachetastic/Caches/RailsSessionCache.html +0 -154
- data/doc/classes/Cachetastic/Connection.html +0 -212
- data/doc/classes/Cachetastic/Errors/UnsupportedAdapter.html +0 -146
- data/doc/classes/Object.html +0 -222
- data/doc/classes/String.html +0 -172
- data/doc/files/lib/cachetastic/adapters/drb_rb.html +0 -115
- data/doc/files/lib/cachetastic/adapters/file_base_rb.html +0 -109
- data/doc/files/lib/cachetastic/adapters/memcache_rb.html +0 -127
- data/doc/files/lib/cachetastic/caches/mack_session_cache_rb.html +0 -107
- data/doc/files/lib/cachetastic/caches/page_cache_rb.html +0 -109
- data/doc/files/lib/cachetastic/caches/rails_session_cache_rb.html +0 -107
- data/doc/files/lib/cachetastic/connection_rb.html +0 -107
- data/doc/files/lib/cachetastic/errors/unsupported_adapter_rb.html +0 -101
- data/doc/files/lib/cachetastic/rails_extensions/active_record_base_rb.html +0 -101
- data/doc/files/lib/cachetastic/rails_extensions/cgi_session_store_rb.html +0 -109
- data/doc/files/lib/cachetastic/ruby_extensions/object_rb.html +0 -101
- data/lib/cachetastic/adapters/drb.rb +0 -51
- data/lib/cachetastic/adapters/file_base.rb +0 -86
- data/lib/cachetastic/adapters/html_file.rb +0 -68
- data/lib/cachetastic/adapters/memcache.rb +0 -114
- data/lib/cachetastic/adapters/store_object.rb +0 -28
- data/lib/cachetastic/caches/base.rb +0 -238
- data/lib/cachetastic/caches/mack_session_cache.rb +0 -3
- data/lib/cachetastic/caches/page_cache.rb +0 -6
- data/lib/cachetastic/caches/rails_session_cache.rb +0 -12
- data/lib/cachetastic/connection.rb +0 -24
- data/lib/cachetastic/errors/unsupported_adapter.rb +0 -7
- data/lib/cachetastic/rails_extensions/active_record_base.rb +0 -24
- data/lib/cachetastic/rails_extensions/cgi_session_store.rb +0 -59
- data/lib/cachetastic/ruby_extensions/kernel.rb +0 -25
- data/lib/cachetastic/ruby_extensions/object.rb +0 -22
- data/lib/cachetastic/ruby_extensions/string.rb +0 -15
- data/test/active_record_test.rb +0 -89
- data/test/cacheable_test.rb +0 -88
- data/test/cachetastic_unit_test.rb +0 -74
- data/test/config.rb +0 -30
- data/test/drb_adapter_test.rb +0 -14
- data/test/file_adapter_test.rb +0 -49
- data/test/memcache_adapter_test.rb +0 -18
- data/test/test_helper.rb +0 -75
data/test/config.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
configatron.my_file_store_cache_options.debug = false
|
2
|
-
configatron.my_file_store_cache_options.adapter = :file
|
3
|
-
configatron.my_file_store_cache_options.store_options.dir = '/cachetastic/test'
|
4
|
-
configatron.my_file_store_cache_options.logger = Logger.new(STDOUT)
|
5
|
-
|
6
|
-
configatron.cachetastic_default_options.debug = false
|
7
|
-
configatron.cachetastic_default_options.adapter = :local_memory
|
8
|
-
configatron.cachetastic_default_options.marshall_method = :none
|
9
|
-
configatron.cachetastic_default_options.default_expiry = 2
|
10
|
-
log = Logger.new(STDOUT)
|
11
|
-
log.level = Logger::DEBUG
|
12
|
-
configatron.cachetastic_default_options.logger = log
|
13
|
-
|
14
|
-
configatron.young_mc_cache_options.debug = true
|
15
|
-
configatron.young_mc_cache_options.adapter = :memcache
|
16
|
-
configatron.young_mc_cache_options.default_expiry = 2
|
17
|
-
configatron.young_mc_cache_options.logger = Logger.new(STDOUT)
|
18
|
-
configatron.young_mc_cache_options.servers = "127.0.0.1:11211"
|
19
|
-
configatron.young_mc_cache_options.store_options.c_threshold = "10_000"
|
20
|
-
configatron.young_mc_cache_options.store_options.compression = true
|
21
|
-
configatron.young_mc_cache_options.store_options.debug = false
|
22
|
-
configatron.young_mc_cache_options.readonly = false
|
23
|
-
configatron.young_mc_cache_options.urlencode = false
|
24
|
-
|
25
|
-
configatron.dr_bob_cache_options.debug = true
|
26
|
-
configatron.dr_bob_cache_options.adapter = :drb
|
27
|
-
configatron.dr_bob_cache_options.default_expiry = 2
|
28
|
-
configatron.dr_bob_cache_options.logger = Logger.new(STDOUT)
|
29
|
-
configatron.dr_bob_cache_options.servers = "druby://127.0.0.1:61676"
|
30
|
-
configatron.dr_bob_cache_options.marshall_method = :ruby
|
data/test/drb_adapter_test.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
-
|
3
|
-
class DrbAdapterTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_drb_adapter
|
6
|
-
assert_nil DrBobCache.get(1)
|
7
|
-
assert DrBobCache.adapter.valid?
|
8
|
-
DrBobCache.set(1, :one)
|
9
|
-
assert_equal :one, DrBobCache.get(1)
|
10
|
-
DrBobCache.expire_all
|
11
|
-
assert_nil DrBobCache.get(1)
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
data/test/file_adapter_test.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
-
|
3
|
-
class FileAdapterTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
FileUtils.rm_rf(c_dir, :verbose => true)
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_directory_created_if_it_doesnt_exist_on_new
|
10
|
-
assert !File.exists?(c_dir)
|
11
|
-
assert_nil MyFileStoreCache.get(1)
|
12
|
-
assert File.exists?(c_dir)
|
13
|
-
assert MyFileStoreCache.adapter.valid?
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_invalid_if_directory_is_deleted
|
17
|
-
assert !File.exists?(c_dir)
|
18
|
-
assert_nil MyFileStoreCache.get(1)
|
19
|
-
assert File.exists?(c_dir)
|
20
|
-
FileUtils.rm_rf(c_dir, :verbose => true)
|
21
|
-
assert !Cachetastic::Connection.instance.connections[:my_file_store_cache].valid?
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_expire_all
|
25
|
-
assert_nil MyFileStoreCache.get(1)
|
26
|
-
MyFileStoreCache.set(1, "hello")
|
27
|
-
assert_equal "hello", MyFileStoreCache.get(1)
|
28
|
-
assert_nil MyFileStoreCache.get(2)
|
29
|
-
MyFileStoreCache.set(2, [1,2,3,4])
|
30
|
-
assert_equal [1,2,3,4], MyFileStoreCache.get(2)
|
31
|
-
MyFileStoreCache.expire_all
|
32
|
-
assert_equal nil, MyFileStoreCache.get(1)
|
33
|
-
assert_equal nil, MyFileStoreCache.get(2)
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_expiry
|
37
|
-
assert_nil MyFileStoreCache.get(1)
|
38
|
-
MyFileStoreCache.set(1, "hello", 1)
|
39
|
-
assert_equal "hello", MyFileStoreCache.get(1)
|
40
|
-
sleep(3)
|
41
|
-
assert_nil MyFileStoreCache.get(1)
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
def c_dir
|
46
|
-
"/cachetastic/test"
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
-
|
3
|
-
class MemcacheAdapterTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
# YoungMcCache.expire_all
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_memcache_adapter
|
10
|
-
assert_nil YoungMcCache.get(1)
|
11
|
-
assert YoungMcCache.adapter.valid?
|
12
|
-
YoungMcCache.set(1, :one)
|
13
|
-
assert_equal :one, YoungMcCache.get(1)
|
14
|
-
YoungMcCache.expire_all
|
15
|
-
assert_nil YoungMcCache.get(1)
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
require File.join(File.dirname(__FILE__), "..", "lib", "cachetastic")
|
3
|
-
require 'rubygems'
|
4
|
-
# require 'mack-facets'
|
5
|
-
require 'active_record'
|
6
|
-
|
7
|
-
# place common methods, assertions, and other type things in this file so
|
8
|
-
# other tests will have access to them.
|
9
|
-
|
10
|
-
require File.join(File.dirname(__FILE__), "config")
|
11
|
-
|
12
|
-
class MyTempOptionsCache < Cachetastic::Caches::Base
|
13
|
-
end
|
14
|
-
|
15
|
-
class YourTempOptionsCache < Cachetastic::Caches::Base
|
16
|
-
end
|
17
|
-
|
18
|
-
class MyFileStoreCache < Cachetastic::Caches::Base
|
19
|
-
end
|
20
|
-
|
21
|
-
class FooBarCache < Cachetastic::Caches::Base
|
22
|
-
end
|
23
|
-
|
24
|
-
class ArAlbumCache < Cachetastic::Caches::Base
|
25
|
-
class << self
|
26
|
-
def get(key, num)
|
27
|
-
logger.info(key, num)
|
28
|
-
super(key) do
|
29
|
-
a = []
|
30
|
-
num.times do
|
31
|
-
a << ArAlbum.find(1)
|
32
|
-
end
|
33
|
-
set(key, a)
|
34
|
-
end
|
35
|
-
end # get
|
36
|
-
end # self
|
37
|
-
end # AlbumCache
|
38
|
-
|
39
|
-
class YoungMcCache < Cachetastic::Caches::Base
|
40
|
-
end
|
41
|
-
|
42
|
-
class DrBobCache < Cachetastic::Caches::Base
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
#---- AR:
|
47
|
-
AR_DB = File.join(Dir.pwd, "ar_test.db")
|
48
|
-
ActiveRecord::Base.establish_connection({:adapter => "sqlite3", :database => AR_DB})
|
49
|
-
|
50
|
-
class ArAlbum < ActiveRecord::Base
|
51
|
-
def some_numbers(arr)
|
52
|
-
cacher(:some_numbers) do
|
53
|
-
arr << :yippie
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
class ArSong < ActiveRecord::Base
|
58
|
-
end
|
59
|
-
|
60
|
-
class ArMigration < ActiveRecord::Migration
|
61
|
-
def self.up
|
62
|
-
create_table :ar_albums do |t|
|
63
|
-
t.column :title, :string
|
64
|
-
t.column :artist, :string
|
65
|
-
end
|
66
|
-
create_table :ar_songs do |t|
|
67
|
-
t.column :title, :string
|
68
|
-
t.column :album_id, :integer
|
69
|
-
end
|
70
|
-
end
|
71
|
-
def self.down
|
72
|
-
drop_table :ar_songs
|
73
|
-
drop_table :ar_albums
|
74
|
-
end
|
75
|
-
end
|