SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Versatile Storage Options
with Tokyo Cabinet
NoSQL Live
March 11, 2010
Flinn Mueller
Tokyo Cabinet
• Mikio Hirabayashi
• Mixi.jp
• LGPL
• C99/Posix
• Successor to QDBM
• mmap
Hash DB

• Key/Value
• Strings
• Extensions (Lua)
• Map/Reduce
• Forward Matching Keys
B+ Tree Store

• Key/Value
• Duplicate Keys
• Forward Matching Keys
• (Perfect Tag Store)
Fixed Length DB

• Key/Value
• Keys As Natural Number
• Value Length Limited
• Faster than Hash or B+ Tree
• Range Query
Table Store

• Tuple/Document Store
• Query (condition, order, limit)
• Full Text Search
• Union, Intersect, Diff
• Parallel Query
How I Use Tokyo

• Like Memcache++
• Like a Queue
• Like a Counter
• Like a Tag Cloud
{}
Like Memcache++
require 'tokyo_tyrant'
t = TokyoTyrant::DB.new

t['example.com/lorem'] = "Lorem..."
t['example.com/lorem']
# => "Lorem..."

t['example.com/lorem/ipsum'] = "Ipsum..."

t.fwmkeys('example.com/')
# => ['example.com/lorem/ipsum', 'example.com/lorem']
Q
Like a Queue
require 'tokyo_tyrant'
tdb = TokyoTyrant::Table.new

tdb[tdb.genuid] = {
    'url' => "http://example.com",
    'queue' => "1m",
    'created_at' => Time.now.to_i,
    'origin' => Socket.hostname
}
Like a Queue

require 'tokyo_tyrant'
tdb = TokyoTyrant::Table.new

tasks = tdb.find{ |q|
    q.condition :queue, :streq, '1m'
    q.order_by :created_at
}.each{ |task| run_process(task) }
i++
Like a Counter

require 'tokyo_tyrant'
COUNTER_DB = TokyoTyrant::DB.new
...

COUNTER_DB.add_int(id)
# => 82169
zomg
pictures

       lolcatz
   funny
Like a Tag Cloud
require 'tokyo_tyrant'
TAG_DB = TokyoTyrant::BDB.new
...

tags = ['foo', 'bar']
tags.collect!{ |tag| "tag:#{tag}:articles" }
hash_tags = TAG_DB.getlist(tags)
article_ids = hash_tags.values.collect.flatten
article_ids = article_ids.uniq.sort.reverse[0..4]

articles = TAG_DB.mget(article_ids)
Related Content
articles = TAG_DB.mget(article_ids)

unpack = proc{ |k,v| v = MessagePack.unpack(v); v['__id'] = k; v }
articles = articles.collect(&unpack).compact
articles = articles.sort_by{ |v| v['__id'] }
articles.reverse!

content = Mustache.render(@@template, :articles => articles)
response = [200, {"Content-Type" => "text/html"}, [content]]
Versatile Storage Options


• Like Memcache++
• Like a Queue
• Like a Counter
• Like a Tag Cloud
More
          http://1978th.net/tokyocabinet
          http://1978th.net/tokyotyrant/
http://groups.google.com/group/tokyocabinet-users/
      http://tokyocabinetwiki.pbworks.com/
   http://github.com/actsasflinn/ruby-tokyotyrant
     http://github.com/jmettraux/rufus-tokyo/

Weitere ähnliche Inhalte

Ähnlich wie Versatile Storage Options With Tokyo Cabinet

Python presentation
Python presentationPython presentation
Python presentation
Julia437584
 
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
Benefits of using MongoDB: Reduce Complexity & Adapt to ChangesBenefits of using MongoDB: Reduce Complexity & Adapt to Changes
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
Alex Nguyen
 
Denis Lebedev, Swift
Denis  Lebedev, SwiftDenis  Lebedev, Swift
Denis Lebedev, Swift
Yandex
 

Ähnlich wie Versatile Storage Options With Tokyo Cabinet (20)

T3dallas typoscript
T3dallas typoscriptT3dallas typoscript
T3dallas typoscript
 
Spring Camp 2016 - List query performance improvement using Couchbase
Spring Camp 2016 - List query performance improvement using CouchbaseSpring Camp 2016 - List query performance improvement using Couchbase
Spring Camp 2016 - List query performance improvement using Couchbase
 
2CPP15 - Templates
2CPP15 - Templates2CPP15 - Templates
2CPP15 - Templates
 
TiDB Introduction - San Francisco MySQL Meetup
TiDB Introduction - San Francisco MySQL MeetupTiDB Introduction - San Francisco MySQL Meetup
TiDB Introduction - San Francisco MySQL Meetup
 
TiDB Introduction - Boston MySQL Meetup Group
TiDB Introduction - Boston MySQL Meetup GroupTiDB Introduction - Boston MySQL Meetup Group
TiDB Introduction - Boston MySQL Meetup Group
 
Python presentation
Python presentationPython presentation
Python presentation
 
Scala Back to Basics: Type Classes
Scala Back to Basics: Type ClassesScala Back to Basics: Type Classes
Scala Back to Basics: Type Classes
 
Datomic – A Modern Database - StampedeCon 2014
Datomic – A Modern Database - StampedeCon 2014Datomic – A Modern Database - StampedeCon 2014
Datomic – A Modern Database - StampedeCon 2014
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
 
In memory databases presentation
In memory databases presentationIn memory databases presentation
In memory databases presentation
 
Master tuning
Master   tuningMaster   tuning
Master tuning
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scala
 
Modern C++
Modern C++Modern C++
Modern C++
 
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
Benefits of using MongoDB: Reduce Complexity & Adapt to ChangesBenefits of using MongoDB: Reduce Complexity & Adapt to Changes
Benefits of using MongoDB: Reduce Complexity & Adapt to Changes
 
Denis Lebedev, Swift
Denis  Lebedev, SwiftDenis  Lebedev, Swift
Denis Lebedev, Swift
 
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
 
MongoDB .local Toronto 2019: MongoDB Atlas Search Deep Dive
MongoDB .local Toronto 2019: MongoDB Atlas Search Deep DiveMongoDB .local Toronto 2019: MongoDB Atlas Search Deep Dive
MongoDB .local Toronto 2019: MongoDB Atlas Search Deep Dive
 
MongoDB at RubyEnRails 2009
MongoDB at RubyEnRails 2009MongoDB at RubyEnRails 2009
MongoDB at RubyEnRails 2009
 
How to use the new Domino Query Language
How to use the new Domino Query LanguageHow to use the new Domino Query Language
How to use the new Domino Query Language
 

KĂźrzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
Christopher Logan Kennedy
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

KĂźrzlich hochgeladen (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Versatile Storage Options With Tokyo Cabinet

  • 1. Versatile Storage Options with Tokyo Cabinet NoSQL Live March 11, 2010 Flinn Mueller
  • 2. Tokyo Cabinet • Mikio Hirabayashi • Mixi.jp • LGPL • C99/Posix • Successor to QDBM • mmap
  • 3. Hash DB • Key/Value • Strings • Extensions (Lua) • Map/Reduce • Forward Matching Keys
  • 4. B+ Tree Store • Key/Value • Duplicate Keys • Forward Matching Keys • (Perfect Tag Store)
  • 5. Fixed Length DB • Key/Value • Keys As Natural Number • Value Length Limited • Faster than Hash or B+ Tree • Range Query
  • 6. Table Store • Tuple/Document Store • Query (condition, order, limit) • Full Text Search • Union, Intersect, Diff • Parallel Query
  • 7. How I Use Tokyo • Like Memcache++ • Like a Queue • Like a Counter • Like a Tag Cloud
  • 8. {}
  • 9. Like Memcache++ require 'tokyo_tyrant' t = TokyoTyrant::DB.new t['example.com/lorem'] = "Lorem..." t['example.com/lorem'] # => "Lorem..." t['example.com/lorem/ipsum'] = "Ipsum..." t.fwmkeys('example.com/') # => ['example.com/lorem/ipsum', 'example.com/lorem']
  • 10. Q
  • 11. Like a Queue require 'tokyo_tyrant' tdb = TokyoTyrant::Table.new tdb[tdb.genuid] = { 'url' => "http://example.com", 'queue' => "1m", 'created_at' => Time.now.to_i, 'origin' => Socket.hostname }
  • 12. Like a Queue require 'tokyo_tyrant' tdb = TokyoTyrant::Table.new tasks = tdb.find{ |q| q.condition :queue, :streq, '1m' q.order_by :created_at }.each{ |task| run_process(task) }
  • 13. i++
  • 14. Like a Counter require 'tokyo_tyrant' COUNTER_DB = TokyoTyrant::DB.new ... COUNTER_DB.add_int(id) # => 82169
  • 15. zomg pictures lolcatz funny
  • 16. Like a Tag Cloud require 'tokyo_tyrant' TAG_DB = TokyoTyrant::BDB.new ... tags = ['foo', 'bar'] tags.collect!{ |tag| "tag:#{tag}:articles" } hash_tags = TAG_DB.getlist(tags) article_ids = hash_tags.values.collect.flatten article_ids = article_ids.uniq.sort.reverse[0..4] articles = TAG_DB.mget(article_ids)
  • 17. Related Content articles = TAG_DB.mget(article_ids) unpack = proc{ |k,v| v = MessagePack.unpack(v); v['__id'] = k; v } articles = articles.collect(&unpack).compact articles = articles.sort_by{ |v| v['__id'] } articles.reverse! content = Mustache.render(@@template, :articles => articles) response = [200, {"Content-Type" => "text/html"}, [content]]
  • 18. Versatile Storage Options • Like Memcache++ • Like a Queue • Like a Counter • Like a Tag Cloud
  • 19. More http://1978th.net/tokyocabinet http://1978th.net/tokyotyrant/ http://groups.google.com/group/tokyocabinet-users/ http://tokyocabinetwiki.pbworks.com/ http://github.com/actsasflinn/ruby-tokyotyrant http://github.com/jmettraux/rufus-tokyo/

Hinweis der Redaktion