aniki has come
TRANSCRIPT
What is Aniki?
• Simple Architecture
• Object Mapping
• Relationship Support
• Pluggable / Extendable
• Fast
Do it simple
• Aniki - provides main interface
• Aniki::Handler - provides DBI handling
• Aniki::Schema - provides Schema meta API
• Aniki::Result - provides SELECT query’s result
• Aniki::Row - provides access to row
Don’t do difficult somethings
• Delegate to:
• DBIx::Handler (DBIx::TransactionManager)
• DBIx::Schema::DSL (SQL::Translator)
• SQL::Maker (SQL::QueryMaker)
• SQL::NamedPlaceholder
Rule of least surprise
• Write clearly a side effect
• e.g.) insert => execute insert only
• e.g.) insert_and_fetch_id
• e.g.) insert_and_fetch_row
• No write clearly, No do it.
Don’t repeat your self
• Abstraction Layers
• Aniki::Handler - connection handling
• Aniki::Reuslt::Collection - collection
• Aniki::Result::Row - row of result
Don’t repeat your self
• Object Mapping
• Relationship Support
• Plugin Architecture
• I’ll talk about these later
Object Mapping
• Map a row to a row object
• Can change the class of object each tables
• Map rows to a collection object
• Also you can it too :)
• And, you can disable it, If you want.
Example:
# $rows is a Aniki::Result::Collectionmy $rows = $db->select(user => {});$rows->first; ## first of row
Example:
# $rows is a Arraymy $rows = $db->select(user => {}, { suppress_result_object => 1,});$rows->[0]; ## first of row
Example:
# $row is a Aniki::Result::Rowmy $row = $db->select(user => { id => 1,}, { limit => 1,})->first;$row->id; ## => 1
Example:
# $row is a Hashmy $row = $db->select(user => { id => 1,}, { limit => 1, suppress_row_objects => 1,})->first;$row->{id}; ## => 1
Relationship Support
• Fetch related rows from ORM
• a.k.a.) prefetch
• Useful for suppress query executions.
Pluggable
• Mo[ou]se::Role is useful for plugin system
• You can write plugin as Mouse::Role for Aniki
Extendable
• Aniki
• Aniki::Handler
• e.g.) Aniki::Handler::WeightedRoundRobin
• Aniki::Result::Row
• Aniki::Result::Collection
Benchmark
• INSERT(and fetch row):
• 18% faster than Teng
• 40% faster than DBIx::Class
• INSERT(and fetch id):
• 21% faster than Teng
Benchmark
• UPDATE(from row):
• 34% slower than Teng
• 49% faster than DBIx::Class
• UPDATE(from where condition):
• 5% faster than Teng
Benchmark
• DELETE(from row):
• 2% slower than Teng
• 422% faster than DBIx::Class
• DELETE(from where condition):
• 5% faster than Teng