SlideShare a Scribd company logo
1 of 18
Key-Value Storage Systems …  and beyond … with Python
Who the hell are you? + + = Ian Lewis Company: BeProud Tags: #python #django #redbull #mercurial Twitter: IanMLewis HP: http://www.ianlewis.org/
Pro: Fast Simple Con: Can't easily store complex relational data Can't do complex queries Why?
What?
Memcached ,[object Object],[object Object],[object Object],[object Object],[object Object]
python-memcached >>>  import  memcache  >>> client = memcache.Client([ "127.0.0.1:11211" ])  >>> client. set ( "test" ,  1 )  True   >>> client. add ( "test" ,  1 )  False   >>> client. add ( "test2" ,  1 )  True   >>> client. set ( "test" ,  2 )  True   >>> client. incr ( "test" )  3   >>>
Tokyo-Cabinet/Tyrant ,[object Object],[object Object],[object Object],[object Object],[object Object]
python-tokyotyrant/pytyrant >>>  import  pytyrant  >>> t = pytyrant.PyTyrant. open ( '127.0.0.1' ,  1978 )  >>> t[ '__test_key__' ] =  'foo'   >>> t. concat ( '__test_key__' ,  'bar' )  >>>  print  t[ '__test_key__' ]  foobar  >>>  del  t[ '__test_key__' ] PY-
B+ Trees
pytc >>>  import  pytc >>> db = pytc.BDB( 'bdb.db' , pytc.BDBOWRITER | pytc.BDBOCREAT) >>> db[ 'niku' ] =  'umai' >>> db[ 'niku' ] 'umai' >>> db[ 'ra-men' ] =  'kuitai' >>> db[ 'ra-men' ] 'kuitai' >>>  for  key  in  db: >>>  print   'key:' , key,  ' value:' , db[key] 'key: niki value: umai' 'key: ra-men value: kuitai'
= ?
redis ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
So I can't eat it?
>>>  from  redis  import  Redis, ConnectionError, ResponseError >>> r = Redis(db= 9 ) >>> r[ 'a' ] =  24 . 0 >>> r[ 'a' ] Decimal( "24.0" ) >>> r = Redis(db= 9 , float_fn= float ) >>> r[ 'a' ] 24 . 0 >>>  del  r[ 'a' ] >>>  print  r.get( 'a' )  # r['a'] will raise KeyError None redis-py
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Cassandra
Cassandra
pycassa import  pycassa CLIENT = pycassa.connect_thread_local(framed_transport= True ) USER = pycassa.ColumnFamily(CLIENT,  'Twissandra' ,  'User' , dict_class=OrderedDict) ... TWEET = pycassa.ColumnFamily(CLIENT,  'Twissandra' ,  'Tweet' , dict_class=OrderedDict) TIMELINE = pycassa.ColumnFamily(CLIENT,  'Twissandra' ,  'Timeline' , dict_class=OrderedDict) ... timeline = TIMELINE.get( str (user_id), column_start=start, column_count=limit, column_reversed= True ) tweets = TWEET.multiget(timeline.values())
Questions!

More Related Content

What's hot

Speeding up Page Load Times by Using the Starling Queue Server
Speeding up Page Load Times by Using the Starling Queue ServerSpeeding up Page Load Times by Using the Starling Queue Server
Speeding up Page Load Times by Using the Starling Queue ServerErik Osterman
 
Old man emu by john williamson
Old man emu by john williamsonOld man emu by john williamson
Old man emu by john williamsonRobyn Scott
 
HTML, WordPress, and SEO
HTML, WordPress, and SEOHTML, WordPress, and SEO
HTML, WordPress, and SEOBrian Whalley
 
Basic HTML CSS Slides
Basic HTML CSS Slides Basic HTML CSS Slides
Basic HTML CSS Slides Allyson Wehrs
 
Kansas City WordCamp - Website Performance
Kansas City WordCamp - Website PerformanceKansas City WordCamp - Website Performance
Kansas City WordCamp - Website PerformanceKevin Potts
 

What's hot (6)

Speeding up Page Load Times by Using the Starling Queue Server
Speeding up Page Load Times by Using the Starling Queue ServerSpeeding up Page Load Times by Using the Starling Queue Server
Speeding up Page Load Times by Using the Starling Queue Server
 
Old man emu by john williamson
Old man emu by john williamsonOld man emu by john williamson
Old man emu by john williamson
 
HTML, WordPress, and SEO
HTML, WordPress, and SEOHTML, WordPress, and SEO
HTML, WordPress, and SEO
 
Website Performance
Website PerformanceWebsite Performance
Website Performance
 
Basic HTML CSS Slides
Basic HTML CSS Slides Basic HTML CSS Slides
Basic HTML CSS Slides
 
Kansas City WordCamp - Website Performance
Kansas City WordCamp - Website PerformanceKansas City WordCamp - Website Performance
Kansas City WordCamp - Website Performance
 

Similar to Key Value Storage Systems ... and Beyond ... with Python

What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?brynary
 
FRDCSA Temporal Planning and Inferencing for Task Management through the Verb...
FRDCSA Temporal Planning and Inferencing for Task Management through the Verb...FRDCSA Temporal Planning and Inferencing for Task Management through the Verb...
FRDCSA Temporal Planning and Inferencing for Task Management through the Verb...aindilis
 
Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Tatsuhiko Miyagawa
 
Perl Teach-In (part 1)
Perl Teach-In (part 1)Perl Teach-In (part 1)
Perl Teach-In (part 1)Dave Cross
 
Why Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, MarakanaWhy Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, MarakanaMarko Gargenta
 
jQuery - Doing it right
jQuery - Doing it rightjQuery - Doing it right
jQuery - Doing it rightgirish82
 
Getting started with MongoDB and PHP
Getting started with MongoDB and PHPGetting started with MongoDB and PHP
Getting started with MongoDB and PHPgates10gen
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Ilya Grigorik
 
Good practices for PrestaShop code security and optimization
Good practices for PrestaShop code security and optimizationGood practices for PrestaShop code security and optimization
Good practices for PrestaShop code security and optimizationPrestaShop
 
Complex Values
Complex ValuesComplex Values
Complex ValuesESUG
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With PhpJeremy Coates
 
Schema design with MongoDB (Dwight Merriman)
Schema design with MongoDB (Dwight Merriman)Schema design with MongoDB (Dwight Merriman)
Schema design with MongoDB (Dwight Merriman)MongoSF
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRick Copeland
 
PHP Presentation
PHP PresentationPHP Presentation
PHP PresentationAnkush Jain
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniternicdev
 
Redis And python at pycon_2011
Redis And python at pycon_2011Redis And python at pycon_2011
Redis And python at pycon_2011sunilar0ra
 
Graph Databases
Graph DatabasesGraph Databases
Graph DatabasesJosh Adell
 
Introducing Modern Perl
Introducing Modern PerlIntroducing Modern Perl
Introducing Modern PerlDave Cross
 
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]Chris Toohey
 

Similar to Key Value Storage Systems ... and Beyond ... with Python (20)

What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
 
FRDCSA Temporal Planning and Inferencing for Task Management through the Verb...
FRDCSA Temporal Planning and Inferencing for Task Management through the Verb...FRDCSA Temporal Planning and Inferencing for Task Management through the Verb...
FRDCSA Temporal Planning and Inferencing for Task Management through the Verb...
 
Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8
 
Perl Teach-In (part 1)
Perl Teach-In (part 1)Perl Teach-In (part 1)
Perl Teach-In (part 1)
 
Why Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, MarakanaWhy Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, Marakana
 
What's New in ZF 1.10
What's New in ZF 1.10What's New in ZF 1.10
What's New in ZF 1.10
 
jQuery - Doing it right
jQuery - Doing it rightjQuery - Doing it right
jQuery - Doing it right
 
Getting started with MongoDB and PHP
Getting started with MongoDB and PHPGetting started with MongoDB and PHP
Getting started with MongoDB and PHP
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
 
Good practices for PrestaShop code security and optimization
Good practices for PrestaShop code security and optimizationGood practices for PrestaShop code security and optimization
Good practices for PrestaShop code security and optimization
 
Complex Values
Complex ValuesComplex Values
Complex Values
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With Php
 
Schema design with MongoDB (Dwight Merriman)
Schema design with MongoDB (Dwight Merriman)Schema design with MongoDB (Dwight Merriman)
Schema design with MongoDB (Dwight Merriman)
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter
 
Redis And python at pycon_2011
Redis And python at pycon_2011Redis And python at pycon_2011
Redis And python at pycon_2011
 
Graph Databases
Graph DatabasesGraph Databases
Graph Databases
 
Introducing Modern Perl
Introducing Modern PerlIntroducing Modern Perl
Introducing Modern Perl
 
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
 

More from Ian Lewis

Appengine ja-night-20110222
Appengine ja-night-20110222Appengine ja-night-20110222
Appengine ja-night-20110222Ian Lewis
 
Twisted ロングポーリング チャット サーバ
Twisted ロングポーリング チャット サーバTwisted ロングポーリング チャット サーバ
Twisted ロングポーリング チャット サーバIan Lewis
 
Sphinx 1.1 i18n 機能紹介
Sphinx 1.1 i18n 機能紹介Sphinx 1.1 i18n 機能紹介
Sphinx 1.1 i18n 機能紹介Ian Lewis
 
BPStudy #40 - Google Appengine 1.4.0
BPStudy #40 - Google Appengine 1.4.0BPStudy #40 - Google Appengine 1.4.0
BPStudy #40 - Google Appengine 1.4.0Ian Lewis
 
Djangoアプリの実践的設計手法
Djangoアプリの実践的設計手法Djangoアプリの実践的設計手法
Djangoアプリの実践的設計手法Ian Lewis
 
Celery Task Queue
Celery Task QueueCelery Task Queue
Celery Task QueueIan Lewis
 
Django O/R Mapper
Django O/R MapperDjango O/R Mapper
Django O/R MapperIan Lewis
 

More from Ian Lewis (7)

Appengine ja-night-20110222
Appengine ja-night-20110222Appengine ja-night-20110222
Appengine ja-night-20110222
 
Twisted ロングポーリング チャット サーバ
Twisted ロングポーリング チャット サーバTwisted ロングポーリング チャット サーバ
Twisted ロングポーリング チャット サーバ
 
Sphinx 1.1 i18n 機能紹介
Sphinx 1.1 i18n 機能紹介Sphinx 1.1 i18n 機能紹介
Sphinx 1.1 i18n 機能紹介
 
BPStudy #40 - Google Appengine 1.4.0
BPStudy #40 - Google Appengine 1.4.0BPStudy #40 - Google Appengine 1.4.0
BPStudy #40 - Google Appengine 1.4.0
 
Djangoアプリの実践的設計手法
Djangoアプリの実践的設計手法Djangoアプリの実践的設計手法
Djangoアプリの実践的設計手法
 
Celery Task Queue
Celery Task QueueCelery Task Queue
Celery Task Queue
 
Django O/R Mapper
Django O/R MapperDjango O/R Mapper
Django O/R Mapper
 

Recently uploaded

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 

Key Value Storage Systems ... and Beyond ... with Python

  • 1. Key-Value Storage Systems … and beyond … with Python
  • 2. Who the hell are you? + + = Ian Lewis Company: BeProud Tags: #python #django #redbull #mercurial Twitter: IanMLewis HP: http://www.ianlewis.org/
  • 3. Pro: Fast Simple Con: Can't easily store complex relational data Can't do complex queries Why?
  • 5.
  • 6. python-memcached >>> import memcache >>> client = memcache.Client([ "127.0.0.1:11211" ]) >>> client. set ( "test" , 1 ) True >>> client. add ( "test" , 1 ) False >>> client. add ( "test2" , 1 ) True >>> client. set ( "test" , 2 ) True >>> client. incr ( "test" ) 3 >>>
  • 7.
  • 8. python-tokyotyrant/pytyrant >>> import pytyrant >>> t = pytyrant.PyTyrant. open ( '127.0.0.1' , 1978 ) >>> t[ '__test_key__' ] = 'foo' >>> t. concat ( '__test_key__' , 'bar' ) >>> print t[ '__test_key__' ] foobar >>> del t[ '__test_key__' ] PY-
  • 10. pytc >>> import pytc >>> db = pytc.BDB( 'bdb.db' , pytc.BDBOWRITER | pytc.BDBOCREAT) >>> db[ 'niku' ] = 'umai' >>> db[ 'niku' ] 'umai' >>> db[ 'ra-men' ] = 'kuitai' >>> db[ 'ra-men' ] 'kuitai' >>> for key in db: >>> print 'key:' , key, ' value:' , db[key] 'key: niki value: umai' 'key: ra-men value: kuitai'
  • 11. = ?
  • 12.
  • 13. So I can't eat it?
  • 14. >>> from redis import Redis, ConnectionError, ResponseError >>> r = Redis(db= 9 ) >>> r[ 'a' ] = 24 . 0 >>> r[ 'a' ] Decimal( "24.0" ) >>> r = Redis(db= 9 , float_fn= float ) >>> r[ 'a' ] 24 . 0 >>> del r[ 'a' ] >>> print r.get( 'a' ) # r['a'] will raise KeyError None redis-py
  • 15.
  • 17. pycassa import pycassa CLIENT = pycassa.connect_thread_local(framed_transport= True ) USER = pycassa.ColumnFamily(CLIENT, 'Twissandra' , 'User' , dict_class=OrderedDict) ... TWEET = pycassa.ColumnFamily(CLIENT, 'Twissandra' , 'Tweet' , dict_class=OrderedDict) TIMELINE = pycassa.ColumnFamily(CLIENT, 'Twissandra' , 'Timeline' , dict_class=OrderedDict) ... timeline = TIMELINE.get( str (user_id), column_start=start, column_count=limit, column_reversed= True ) tweets = TWEET.multiget(timeline.values())