activerecord_idnamecache 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1,51 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # bundler
13
+ .bundle
14
+
15
+ # jeweler generated
16
+ pkg
17
+
18
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
19
+ #
20
+ # * Create a file at ~/.gitignore
21
+ # * Include files you want ignored
22
+ # * Run: git config --global core.excludesfile ~/.gitignore
23
+ #
24
+ # After doing this, these files will be ignored in all your git projects,
25
+ # saving you from having to 'pollute' every project you touch with them
26
+ #
27
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
28
+ #
29
+ # For MacOS:
30
+ #
31
+ #.DS_Store
32
+
33
+ # For TextMate
34
+ #*.tmproj
35
+ #tmtags
36
+
37
+ # For emacs:
38
+ #*~
39
+ #\#*
40
+ #.\#*
41
+
42
+ # For vim:
43
+ #*.swp
44
+
45
+ # For redcar:
46
+ #.redcar
47
+
48
+ # For rubinius:
49
+ #*.rbc
50
+ Gemfile.lock
51
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
@@ -0,0 +1,20 @@
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.
@@ -0,0 +1,60 @@
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.
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
@@ -0,0 +1,13 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'activerecord_idnamecache'
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"
7
+ s.authors = ["David Chen"]
8
+ s.email = 'mvjome@gmail.com'
9
+ s.homepage = 'http://github.com/mvj3/activerecord_idnamecache'
10
+
11
+ s.files = `git ls-files`.split("\n")
12
+ s.require_paths = ["lib"]
13
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'activerecord_idnamecache'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,4 @@
1
+ require 'helper'
2
+
3
+ class TestActiverecordIdnamecache < Test::Unit::TestCase
4
+ end
metadata CHANGED
@@ -1,65 +1,58 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: activerecord_idnamecache
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - David Chen
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-03-05 00:00:00 Z
12
+ date: 2013-05-31 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
- description: A simple hello world gem
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
22
17
  email: mvjome@gmail.com
23
18
  executables: []
24
-
25
19
  extensions: []
26
-
27
20
  extra_rdoc_files: []
28
-
29
- files:
21
+ files:
22
+ - .document
23
+ - .gitignore
24
+ - Gemfile
25
+ - LICENSE.txt
26
+ - README.rdoc
27
+ - Rakefile
28
+ - VERSION
29
+ - activerecord_idnamecache.gemspec
30
30
  - lib/activerecord_idnamecache.rb
31
- homepage: http://rubygems.org/gems/activerecord_idnamecache
31
+ - test/helper.rb
32
+ - test/test_activerecord_idnamecache.rb
33
+ homepage: http://github.com/mvj3/activerecord_idnamecache
32
34
  licenses: []
33
-
34
35
  post_install_message:
35
36
  rdoc_options: []
36
-
37
- require_paths:
37
+ require_paths:
38
38
  - lib
39
- required_ruby_version: !ruby/object:Gem::Requirement
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
40
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
48
- required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
46
  none: false
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- hash: 3
54
- segments:
55
- - 0
56
- version: "0"
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
57
51
  requirements: []
58
-
59
52
  rubyforge_project:
60
- rubygems_version: 1.8.10
53
+ rubygems_version: 1.8.25
61
54
  signing_key:
62
55
  specification_version: 3
63
- summary: Use Mysql AUTO_INCREMENT to support key value cache, which should be combined by an integer and string.
56
+ summary: Use Mysql AUTO_INCREMENT to support key value cache, which should be combined
57
+ by an integer and string.
64
58
  test_files: []
65
-