activerecord_idnamecache 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,59 @@
1
+ activerecord_idnamecache
2
+ ==========================================
3
+ Use Mysql AUTO_INCREMENT to support key value cache, which should be combined by an integer and string.
4
+ It means to reduce the database storage size, and improve query performance.
5
+
6
+ All cache will store in process memory, and will never be expired, until the process dies, so the less kvs you use, the better performance you will get. BTW, 100,0000 general strings use 10MB memory.
7
+
8
+ Some relatived articles:
9
+ http://en.wikipedia.org/wiki/Correlation_database
10
+
11
+ Usage
12
+ ------------------------------------------
13
+ ## setup
14
+
15
+ ```ruby
16
+ create_table :kv_browser_names, :options => 'ENGINE=MyISAM DEFAULT CHARSET=utf8' do |t|
17
+ t.string :name
18
+ t.timestamps
19
+ end
20
+
21
+ class KvBrowserName < ActiveRecord::Base
22
+ include IdNameCache
23
+ end
24
+ ```
25
+
26
+ or
27
+
28
+ ```ruby
29
+ create_table :common_tag, :options => 'ENGINE=MyISAM DEFAULT CHARSET=utf8' do |t|
30
+ t.integer :tagid
31
+ t.string :tagname
32
+ end
33
+
34
+ class CommonTag < ActiveRecord::Base
35
+ self.table_name = :common_tag
36
+ self.primary_key = :tagid
37
+
38
+ include IdNameCache; set_key_value :tagid, :tagname
39
+ # include IdNameCache; set_key_value_without_create :tagid, :tagname # if you dont want create it automately
40
+ end
41
+ ```
42
+
43
+ ### use cases
44
+
45
+ ```text
46
+ ruby-1.9.3-rc1 :001 > QuizTag[1]
47
+ QuizTag Load (0.3ms) SELECT `common_tag`.* FROM `common_tag` WHERE `common_tag`.`tagid` = 1 LIMIT 1
48
+ => "Android"
49
+ ruby-1.9.3-rc1 :002 > QuizTag[1]
50
+ => "Android"
51
+ ruby-1.9.3-rc1 :003 > QuizTag['Android']
52
+ QuizTag Load (0.5ms) SELECT `common_tag`.* FROM `common_tag` WHERE `common_tag`.`tagname` = 'Android' LIMIT 1
53
+ => 1
54
+ ruby-1.9.3-rc1 :004 > QuizTag['Android']
55
+ => 1
56
+ ```
57
+
58
+ == Copyright
59
+ MIT, David Chen at eoe.cn
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'activerecord_idnamecache'
3
3
  s.version = File.read("VERSION").strip
4
- s.date = '2013-05-31'
5
- s.summary = "Use Mysql AUTO_INCREMENT to support key value cache, which should be combined by an integer and string."
6
- s.description = s.summary + " If cache hit ratio is high, performance will be better, and so does the memory usage rate"
4
+ s.date = '2013-06-22'
5
+ s.summary = File.read("README.markdown").split(/===+/)[0].strip
6
+ s.description = s.summary
7
7
  s.authors = ["David Chen"]
8
8
  s.email = 'mvjome@gmail.com'
9
9
  s.homepage = 'http://github.com/mvj3/activerecord_idnamecache'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_idnamecache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,9 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-31 00:00:00.000000000 Z
12
+ date: 2013-06-22 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: Use Mysql AUTO_INCREMENT to support key value cache, which should be
15
- combined by an integer and string. If cache hit ratio is high, performance will
16
- be better, and so does the memory usage rate
14
+ description: activerecord_idnamecache
17
15
  email: mvjome@gmail.com
18
16
  executables: []
19
17
  extensions: []
@@ -22,8 +20,7 @@ files:
22
20
  - .document
23
21
  - .gitignore
24
22
  - Gemfile
25
- - LICENSE.txt
26
- - README.rdoc
23
+ - README.markdown
27
24
  - Rakefile
28
25
  - VERSION
29
26
  - activerecord_idnamecache.gemspec
@@ -53,6 +50,5 @@ rubyforge_project:
53
50
  rubygems_version: 1.8.25
54
51
  signing_key:
55
52
  specification_version: 3
56
- summary: Use Mysql AUTO_INCREMENT to support key value cache, which should be combined
57
- by an integer and string.
53
+ summary: activerecord_idnamecache
58
54
  test_files: []
@@ -1,20 +0,0 @@
1
- Copyright (c) 2013 David Chen
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,60 +0,0 @@
1
- = activerecord_idnamecache
2
-
3
- Use Mysql AUTO_INCREMENT to support key value cache, which should be combined by an integer and string.
4
- It means to reduce the database storage size, and improve query performance.
5
-
6
- Some relatived articles:
7
- http://en.wikipedia.org/wiki/Correlation_database
8
-
9
- == Usage
10
-
11
- === setup
12
- create_table :kv_browser_names, :options => 'ENGINE=MyISAM DEFAULT CHARSET=utf8' do |t|
13
- t.string :name
14
- t.timestamps
15
- end
16
-
17
- class KvBrowserName < ActiveRecord::Base
18
- include IdNameCache
19
- end
20
-
21
- or
22
-
23
- create_table :common_tag, :options => 'ENGINE=MyISAM DEFAULT CHARSET=utf8' do |t|
24
- t.integer :tagid
25
- t.string :tagname
26
- end
27
-
28
- class CommonTag < ActiveRecord::Base
29
- self.table_name = :common_tag
30
- self.primary_key = :tagid
31
-
32
- include IdNameCache; set_key_value :tagid, :tagname
33
- # include IdNameCache; set_key_value_without_create :tagid, :tagname # if you dont want create it automately
34
- end
35
-
36
- === use cases
37
- ruby-1.9.3-rc1 :001 > QuizTag[1]
38
- QuizTag Load (0.3ms) SELECT `common_tag`.* FROM `common_tag` WHERE `common_tag`.`tagid` = 1 LIMIT 1
39
- => "Android"
40
- ruby-1.9.3-rc1 :002 > QuizTag[1]
41
- => "Android"
42
- ruby-1.9.3-rc1 :003 > QuizTag['Android']
43
- QuizTag Load (0.5ms) SELECT `common_tag`.* FROM `common_tag` WHERE `common_tag`.`tagname` = 'Android' LIMIT 1
44
- => 1
45
- ruby-1.9.3-rc1 :004 > QuizTag['Android']
46
- => 1
47
-
48
- == Contributing to activerecord_idnamecache
49
-
50
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
51
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
52
- * Fork the project.
53
- * Start a feature/bugfix branch.
54
- * Commit and push until you are happy with your contribution.
55
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
56
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
57
-
58
- == Copyright
59
-
60
- Copyright (c) 2013 David Chen at eoe.cn. See LICENSE.txt for further details.