This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fix memory caching in dev mode | |
# put this in config/initializers/fix_caching_in_dev.rb | |
# Hopefully this won't be needed for long, this fixes cache calls (due to class reloading in dev) | |
# http://blog.bashme.org/2008/07/25/rails-21-model-caching-issue/ | |
if ActiveSupport::Dependencies.mechanism == :load | |
module ActiveSupport | |
module Cache | |
class Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "rbench" | |
def omg_slow | |
return 1 | |
end | |
def omg_fast | |
1 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'tokyo_tyrant' | |
TYRANT = TokyoTyrant::Table.new | |
AMOUNT_RECORDS = 8000 | |
$TYRANT_ID = 0 | |
RECORD = { | |
"component_version" => "X", | |
"state" => "Analyze", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tyrannical | |
require 'tokyo_tyrant' | |
class TrueClass | |
def to_tokyo_tyrant;"1";end | |
end | |
class FalseClass | |
def to_tokyo_tyrant;"0";end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'tokyo_tyrant' | |
$tyrant = TokyoTyrant::Table.new | |
module Cacheable | |
module TyrantTable | |
def self.included(base) #:nodoc: | |
super | |
base.class_eval %q{ | |
cattr_accessor :cache_records | |
@@cache_records = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'tokyo_tyrant' | |
t = TokyoTyrant::Table.new('127.0.0.1', 1978) | |
100.times do |i| | |
t[i] = { 'name' => "Pat #{i}", 'sex' => i % 2 > 0 ? 'male' : 'female' } | |
end | |
q = t.query | |
q.condition('sex', :streq, 'male') | |
q.limit(5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# URL shortener used to benchmark redis-rb and RubyRedis applied to ruby-tokyotyrant | |
# Script takes 1.2 seconds | |
require 'rubygems' | |
require 'benchmark' | |
require 'tokyo_tyrant' | |
puts Benchmark.realtime{ | |
T=TokyoTyrant::DB.new('127.0.0.1', 45000) | |
def shorten(url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# use this to install the same gems you have installed under one ruby in another | |
# run "gem list > ~/Desktop/gems.txt" | |
# run "ruby install_gems.rb /Users/r38y/Desktop/gems.txt" | |
gems = IO.readlines(ARGV.first) | |
gems.map! do |g| | |
stuff = g.split(' ') | |
gem_name = stuff.delete_at(0) | |
stuff.map{|v| v.gsub(/[\(\)\,]/, '')}.map{|v| "sudo gem install #{gem_name} -v=#{v}"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
Tokyo Tyrant Bulk Table Operations Benchmark | |
TokyoTyrant (C) | |
user system total real | |
bulk writing data 0.180000 0.000000 0.180000 ( 0.292081) | |
bulk reading data 0.120000 0.020000 0.140000 ( 0.216074) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
Tokyo Tyrant Bulk Operations Benchmark | |
TokyoTyrant::RDB (Ruby) mget | |
user system total real | |
inserting data 7.770000 1.870000 9.640000 ( 12.598373) | |
reading data 1.540000 0.250000 1.790000 ( 2.290628) | |