cachy 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +6 -7
- data/Rakefile +4 -15
- data/VERSION +1 -1
- data/cachy.gemspec +8 -7
- data/lib/cachy.rb +10 -6
- data/rdoc/README.rdoc +1 -0
- data/spec/spec_helper.rb +2 -3
- metadata +5 -4
data/README.markdown
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Caching library to simplify and organize caching.
|
2
2
|
|
3
3
|
- I18n (seperate caches by locale / expires all locales)
|
4
|
-
- Generation based (expire all caches of one type)
|
5
|
-
- Simultanouse caching (multiple processes trying to write same cache at once)
|
4
|
+
- Generation based (your able expire all caches of one type)
|
5
|
+
- Simultanouse caching (handle multiple processes trying to write same expensive cache at once)
|
6
6
|
- Dependent caches (x caches result of cache z+y -> z changes -> x changes)
|
7
7
|
- Hashed keys (optional -> short/unreadable)
|
8
|
-
- Global cache_version (expire everything Cachy cached)
|
8
|
+
- Global cache_version (expire everything Cachy cached, but not e.g. sessions)
|
9
9
|
- ...
|
10
10
|
- works out of the box with Rails
|
11
11
|
- works with pure Memcache and [Moneta](http://github.com/wycats/moneta/tree/master)(-> Tokyo Cabinet / CouchDB / S3 / Berkeley DB / DataMapper / Memory store)
|
@@ -15,7 +15,6 @@ Install
|
|
15
15
|
As Gem: ` sudo gem install cachy `
|
16
16
|
Or as Rails plugin: ` script/plugins install git://github.com/grosser/cachy.git `
|
17
17
|
|
18
|
-
|
19
18
|
Usage
|
20
19
|
=====
|
21
20
|
###Cachy.cache
|
@@ -24,14 +23,14 @@ Usage
|
|
24
23
|
result = Cachy.cache(:a_key, 'something else', Date.today.day){ expensive() }
|
25
24
|
|
26
25
|
####Cache expensive operation that is run many times by many processes
|
27
|
-
Example
|
26
|
+
Example: at application startup 20 processes try to set the same cache -> 20 heavy database requests -> database timeout -> cache still empty -> ... -> death
|
28
27
|
|
29
28
|
# 19 Processes get [], 1 makes the request -- when cached all get the same result
|
30
29
|
result = Cachy.cache(:a_key, :while_running=>[]){ block_db_for_5_seconds }
|
31
30
|
|
32
31
|
|
33
32
|
####Seperate version for each key
|
34
|
-
Expire all all caches of one kind when
|
33
|
+
Expire all all caches of one kind when code inside the cache has been updated
|
35
34
|
|
36
35
|
100.times{ Cachy.cache(:a_key, rand(100000) ){ expensive() } }
|
37
36
|
Cachy.increment_key(:a_key) --> everything expired
|
@@ -107,7 +106,7 @@ No I18n.available_locales ?
|
|
107
106
|
|
108
107
|
TODO
|
109
108
|
====
|
110
|
-
- optionally store dependent keys (:keys=>xxx), so that they can be setup up once and
|
109
|
+
- optionally store dependent keys (:keys=>xxx), so that they can be setup up once and do not need to be remembered
|
111
110
|
|
112
111
|
Authors
|
113
112
|
=======
|
data/Rakefile
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
files = FileList['spec/**/*_spec.rb']
|
5
|
-
system("spec #{options} #{files}")
|
6
|
-
end
|
7
|
-
|
1
|
+
task :default => :spec
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
Spec::Rake::SpecTask.new {|t| t.spec_opts = ['--color']}
|
8
4
|
|
9
5
|
begin
|
10
6
|
require 'jeweler'
|
@@ -15,16 +11,9 @@ begin
|
|
15
11
|
gem.email = "grosser.michael@gmail.com"
|
16
12
|
gem.homepage = "http://github.com/grosser/#{project_name}"
|
17
13
|
gem.authors = ["Michael Grosser"]
|
18
|
-
gem.rubyforge_project = project_name
|
19
|
-
end
|
20
|
-
|
21
|
-
# fake task so that rubyforge:release works
|
22
|
-
task :rdoc do
|
23
|
-
`mkdir rdoc`
|
24
|
-
`echo documentation is at http://github.com/grosser/#{project_name} > rdoc/README.rdoc`
|
25
14
|
end
|
26
15
|
|
27
|
-
Jeweler::
|
16
|
+
Jeweler::GemcutterTasks.new
|
28
17
|
rescue LoadError
|
29
18
|
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
30
19
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/cachy.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cachy}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Grosser"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-11-22}
|
13
13
|
s.email = %q{grosser.michael@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.markdown"
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
"lib/cachy/memcached_wrapper.rb",
|
24
24
|
"lib/cachy/moneta_wrapper.rb",
|
25
25
|
"lib/cachy/wrapper.rb",
|
26
|
+
"rdoc/README.rdoc",
|
26
27
|
"spec/cachy/memcached_wrapper_spec.rb",
|
27
28
|
"spec/cachy/moneta_wrapper_spec.rb",
|
28
29
|
"spec/cachy_spec.rb",
|
@@ -32,14 +33,13 @@ Gem::Specification.new do |s|
|
|
32
33
|
s.homepage = %q{http://github.com/grosser/cachy}
|
33
34
|
s.rdoc_options = ["--charset=UTF-8"]
|
34
35
|
s.require_paths = ["lib"]
|
35
|
-
s.rubyforge_project = %q{cachy}
|
36
36
|
s.rubygems_version = %q{1.3.5}
|
37
37
|
s.summary = %q{Caching library for projects that have many processes or many caches}
|
38
38
|
s.test_files = [
|
39
|
-
"spec/
|
39
|
+
"spec/spec_helper.rb",
|
40
|
+
"spec/test_cache.rb",
|
40
41
|
"spec/cachy/memcached_wrapper_spec.rb",
|
41
42
|
"spec/cachy/moneta_wrapper_spec.rb",
|
42
|
-
"spec/spec_helper.rb",
|
43
43
|
"spec/cachy_spec.rb"
|
44
44
|
]
|
45
45
|
|
@@ -53,3 +53,4 @@ Gem::Specification.new do |s|
|
|
53
53
|
else
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
data/lib/cachy.rb
CHANGED
@@ -119,14 +119,18 @@ class Cachy
|
|
119
119
|
self.cache_store = ActionController::Base.cache_store if defined? ActionController::Base
|
120
120
|
|
121
121
|
# locales
|
122
|
-
|
123
|
-
|
122
|
+
@@locales = nil
|
123
|
+
def self.locales=(x)
|
124
|
+
@@locales = x
|
124
125
|
end
|
125
126
|
|
126
|
-
self.locales
|
127
|
-
|
128
|
-
|
129
|
-
|
127
|
+
def self.locales
|
128
|
+
return @@locales if @@locales
|
129
|
+
if defined?(I18n) and I18n.respond_to?(:available_locales)
|
130
|
+
I18n.available_locales
|
131
|
+
else
|
132
|
+
[]
|
133
|
+
end
|
130
134
|
end
|
131
135
|
|
132
136
|
private
|
data/rdoc/README.rdoc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
documentation is at http://github.com/grosser/cachy
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cachy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-22 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -30,6 +30,7 @@ files:
|
|
30
30
|
- lib/cachy/memcached_wrapper.rb
|
31
31
|
- lib/cachy/moneta_wrapper.rb
|
32
32
|
- lib/cachy/wrapper.rb
|
33
|
+
- rdoc/README.rdoc
|
33
34
|
- spec/cachy/memcached_wrapper_spec.rb
|
34
35
|
- spec/cachy/moneta_wrapper_spec.rb
|
35
36
|
- spec/cachy_spec.rb
|
@@ -58,14 +59,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
59
|
version:
|
59
60
|
requirements: []
|
60
61
|
|
61
|
-
rubyforge_project:
|
62
|
+
rubyforge_project:
|
62
63
|
rubygems_version: 1.3.5
|
63
64
|
signing_key:
|
64
65
|
specification_version: 3
|
65
66
|
summary: Caching library for projects that have many processes or many caches
|
66
67
|
test_files:
|
68
|
+
- spec/spec_helper.rb
|
67
69
|
- spec/test_cache.rb
|
68
70
|
- spec/cachy/memcached_wrapper_spec.rb
|
69
71
|
- spec/cachy/moneta_wrapper_spec.rb
|
70
|
-
- spec/spec_helper.rb
|
71
72
|
- spec/cachy_spec.rb
|