Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
クラスビルダの話とMongoDB.pm
Search
mackee
May 17, 2013
Programming
0
69
クラスビルダの話とMongoDB.pm
mackee
May 17, 2013
Tweet
Share
More Decks by mackee
See All by mackee
perl for shell, awk and sed programmers
mackee
2
1.3k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
63
マイクロサービス化を利用した Goへの移行事例
mackee
0
100
PerlでつくるフルスクラッチWebAuthn/パスキー認証 / Demonstration of full-scratch WebAuthn/Passkey Authentication written in Perl
mackee
3
3.2k
SRE定例やその辺の取り組みをアプリケーションエンジニア目線で語る / "Observe" about SRE Meeting by Application Engineer
mackee
0
1.8k
TinyGoで使えるORM sqllaの 紹介とTinyGoで使えるようにするための工夫
mackee
0
1.1k
Go向けORM sqllaの紹介と JOINやUNIONを含んだクエリの扱い方
mackee
0
4.4k
デプロイ今昔物語 〜CGIからサーバーレスまで〜 / The deployment technics
mackee
10
12k
E2Eテストから負荷試験シナリオを作ってみた / Why do we make a scenario of load testing from E2E testing scenarios
mackee
3
5.4k
Other Decks in Programming
See All in Programming
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
4
640
Ethereum_.pdf
nekomatu
0
460
cmp.Or に感動した
otakakot
2
150
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
330
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
What's in a price? How to price your products and services
michaelherold
243
12k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Rails Girls Zürich Keynote
gr2m
94
13k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Transcript
PerlͷΫϥεϏϧμʔͷϞδϡʔϧͱ MongoDBͷ @mackee_w Ϛίϐοϐ 135݄30༵
PerlͰΫϥεΛ࡞Δ Ϟδϡʔϧແ͠ͰΫϥεΛ࡞Δʹ package Sheep { sub new { my $class
= shift; my $self = { color => “white” }; return bless $self, $class; } } ৄ͘͠perldocͷperlbootͱ͔ 135݄30༵
ͰΊΜͲ͍͘͞Μʁ ΞτϦϏϡʔτʹΞΫηε͢Δͷʹ$self->{color} ͱ͔Μͳ͍ͱ͍͚ͳ͍͠ɺsubͰ͘ΔͷΊΜ Ͳ͍͘͞Μʁ 135݄30༵
ͦ͜ͰΫϥεϏϧμʔ ͦΕͬΆ͍ײ͡ͰΦϒδΣΫτΛ࡞ΕΔ Class::Accessor::Liteͩͱ͜Μͳײ͡ package Sheep { use Class::Accessor::Lite ( new
=> 1, rw => qw/color/, ); } 135݄30༵
Class::Accessorܥ جຊతʹϓϩύςΟ/ΞΫηαΛউखʹΑ͠ͳʹ ͬͯ͘ΕΔ͚ͩͰɺଞͷݴޠ͕ࡌ͍ͯ͠ΔΑ ͏ͳศརػೳ(abstractͱ͔traitͱ͔privateϓϩύ ςΟͱ͔)ͳ͍ 135݄30༵
͍Ζ͍Ζ͋Δͧ Class::Accessor ݩ Class::Accessor::Fast ……͔ͬͨ Class::Accesor::Lite Tengͱ͔ͰΘΕ͍ͯΔFastΑΓૣ͍ جຊతʹ͜Ε͓͏ Class::Accessor::Tiny ϑΝΠϧαΠζ͍ܰͳͬͯࢥͬͨΒ19ߦͩͬͨ
135݄30༵
ͬͱΦϒδΣΫτΦϒ δΣΫτͨ͠ʔʔʔʔ͍ ྫ͑mix-inͱ͔ɺϝλϓϩతͳΞϨʁ͋ΔΜʁ RubyͬͯΔਓ͕ϞςΔͷͬͯɺ͔͢͠Δͱϝ λϓϩΛΨϦΨϦͬͯΔ͔Β͔͠Εͳ͍ʂ PerlͰϝλϓϩΔͱϞςΔ͔ʂ 135݄30༵
Moose Mouse Moo ϔϥδΧɹωζϛɹڇ ͍͍ͩͨ͜ͷลΓ͏ͱΞΫηαͷܕΛࢦఆͰ͖ ͨΓɺmix-inΈ͍ͨͳ͜ͱ͕ग़དྷͨΓɺϝλϓϩ ग़དྷͨΓศརػೳ͕ͨ͘͞Μ͋Δ 135݄30༵
MouseͰ͕ΜΔ package Sheep { use Mouse; has color => (
is => ‘rw’, isa => ‘Str’, default => sub { ‘white’ }, ); no Mouse; } 135݄30༵
Moose ݩϞμϯPerlͷOOPϞδϡʔϧ ͰΫιॏ͍ CatalystͳͲͷग़͕ࣗݹΊͷϞδϡʔϧͰґଘͯ͠ ͍Δ͜ͱ͕͋Δ 135݄30༵
Mouse ΄΅MooseͷΦϒδΣΫτγεςϜΛແۤૣ ͨ͘͠Ϡπ ҆৺ͱ৴པͱࠇຐज़ͷgfxΣΞ blessΑΓ͍Β͍͠ɻҙຯ͕Θ͔Βͳ͍ ࠃͰ͜ΕΛ͍·͠ΐ͏ 135݄30༵
Any::Moose ΦϫίϯͳͷͰΘͳ͍Α͏ʹ͠·͠ΐ͏ ͳ͓ɺ0.2ܥ·ͰͷArk͕ґଘ͍ͯ͠·͕͢0.3ܥ͔ ΒMouseʹΓସΘΓ·ͨ͠ ิ͢ΔͱɺMooseͱMouseͷͲ͔͍͍ͬͪ΄͏ Λ͏·͍͜ͱͬͯ͘ΕΔϥούʔͰ͢ 135݄30༵
Moo ւ֎Ͱྲྀߦ͍ͬͯΔΒ͍͠ ͍ΒΜͱ͜ΖলུՄͯ͋͠ΔఔಡΊΔײ͡Ͱ ͔͍ͭײ͡ʹ͍ͯ͠ΔΒ͍͠ ؾΛൈ͘ͱMooseʹม͢Δ(metaͱ͔) CPANʹ্͛ͨͯ͘ւ֎ͰΘΕ͍ͨͳΒ͜Ε 135݄30༵
݁ blessΊΜͲ͍͘͞ͷͰΊͱ͜͏ ΞΫηα͔͠ཁΒͳ͍ͳΒClass::Accessor::LiteͰ ͍͍Μ͡Όͳ͍͔ͳ ͕ͬͭΓOOP͍ͨ͠ͳΒMouseͰ ւ֎έΛૂ͏ͱ͔Mooseͷͭॻ͖͑Δͱ͖ MooͰ 135݄30༵
ւ֎έΛૂ͏ͱ͔Mooseͷͭॻ͖͑Δͱ͖ MooͰ 135݄30༵
MongoDB.pm meets Mouse 135݄30༵
MongoDBͱ 135݄30༵
ಛ εΩʔϚϨε جຊతʹΩʔͱυΩϡϝϯτͱ͍͏͚ؔͩΕͲɺυΩϡ ϝϯτͷͰݕࡧग़དྷͨΓ͢Δ ΠϯσοΫεషΕΔ JSONͬΆ͍ײ͡ͷܗࣜͰอଘ͞ΕΔ(BSON) JavaScriptͷ࣮ߦΤϯδϯੵΜͰΔͷͰؔͱ͔JSͰॻ͚Δ 135݄30༵
͜Μͳײ͡ db.collection.save({ user_id: 1 }) db.collection.find({ user_id: 1 }) db.collection.find({
user_id: { $gte: 0 }) 135݄30༵
ϩάͬΆ͍͜ͱͰ͖Δ capped collectionͱݴͬͯ͋ΔҰఆ༰ྔ·ͰஷΊ ͜ΜͰɺ͋;ΕͨΒݹ͍ͷ͔Βফ͍͍ͯͬͯ͘͠ ͏collection͕࡞ΕΔ 135݄30༵
MongoDB.pm is Moose 135݄30༵