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
Introduction to Aerospike with PHP
Search
Mariusz Gil
March 12, 2015
Programming
870
8
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to Aerospike with PHP
Mariusz Gil
March 12, 2015
More Decks by Mariusz Gil
See All by Mariusz Gil
Aspect Oriented Programming
mariuszgil
1
340
Designing and implementing GraphQL API
mariuszgil
1
110
Discovering unknown with EventStorming ConFoo
mariuszgil
0
320
Game of Developer Life... Deconstructed
mariuszgil
1
200
Back to forgotten roots
mariuszgil
1
430
Go micro with microservices
mariuszgil
5
710
Machine Learning for the rescue
mariuszgil
0
450
Discovering graph structures
mariuszgil
3
560
Processing events at scale
mariuszgil
2
390
Other Decks in Programming
See All in Programming
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
11
4.3k
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
550
ふつうのFeature Flag実践入門
irof
8
4.1k
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
180
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
720
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
11
6k
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
160
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
350k
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
スマートグラスで並列バイブコーディング
hyshu
0
250
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
120
Featured
See All Featured
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
210
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
Typedesign – Prime Four
hannesfritz
42
3.1k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
150
It's Worth the Effort
3n
188
29k
Writing Fast Ruby
sferik
630
63k
The Limits of Empathy - UXLibs8
cassininazir
1
360
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
Automating Front-end Workflow
addyosmani
1370
210k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
220
Rails Girls Zürich Keynote
gr2m
96
14k
Transcript
M a r i u s z G i l
P H P
about me
frontend application cache data store
data store
data store scaling is hard
SQL way denormalization / partitioning / sharding
id username attribute_1 attribute_2 1 atermida 1 5 2 saturn
3 2 3 zeus 3 7 … … … …
id username attribute_1 attribute_2 1 atermida 1 2 saturn 2
3 zeus 3 7 … … … … attribute_n 9 …
id username 1 atermida 2 saturn 3 zeus … …
user_id attribute_id value 1 342 1 2 342 2 3 343 3 … … … user_id attribute_id value 1 348 abc 2 348 abd 3 900 eee … … …
noSQL way scalability / consistency / availability / partitioning
None
None
None
namespaces sets records bins
nodes clusters namespaces sets
id username attr_1 attr_2 attr_3 1 atermida 1 2 saturn
2 3 zeus [1, 3, 4] … … … … …
simple and complex data types
aql> insert into test.users (PK, username, attr_1) values ('atena', 'atena',
1); OK, 1 record affected. aql> insert into test.users (PK, username, attr_2) values ('zeus', 'zeus', 2); OK, 1 record affected. aql> insert into test.users (PK, username, attr_3) values ('saturn', 'saturn', 'JSON{"account": "silver", "balance":0}'); OK, 1 record affected. aql> select * from test.users +----------+--------+--------+-----------------------------------+ | username | attr_2 | attr_1 | attr_3 | +----------+--------+--------+-----------------------------------+ | "zeus" | 2 | | | | "atena" | | 1 | | | "saturn" | | | {"account":"silver", "balance":0} | +----------+--------+--------+-----------------------------------+ 3 rows in set (0.375 secs) aql> select * from test.users where PK='atena' +----------+--------+ | username | attr_1 | +----------+--------+ | "atena" | 1 | +----------+--------+ 1 row in set (0.000 secs)
record and stream Lua UDFs
aql> execute list.push('mylist', 'a') on test.demo where PK = '1'
+------+ | push | +------+ | 1 | +------+ 1 row in set (0.000 secs) aql> execute list.push('mylist', 'b') on test.demo where PK = '1' +------+ | push | +------+ | 2 | +------+ 1 row in set (0.000 secs) aql> execute list.push('mylist', 'c') on test.demo where PK = '1' +------+ | push | +------+ | 3 | +------+ 1 row in set (0.000 secs) aql> execute list.peek('mylist', 3) on test.demo where PK = '1' +--------------------------+ | peek | +--------------------------+ | ["c", "b", "a"] | +--------------------------+ 1 row in set (0.000 secs)
PHP way native client
installation # Install dependencies sudo apt-get install build-essential autoconf libssl-dev
sudo apt-get install php5-dev php-pear # Build extension composer require aerospike/aerospike-client-php "*" find vendor/aerospike/aerospike-client-php/ -name "*.sh" -exec chmod +x {} \; cd vendor/aerospike/aerospike-client-php/ && composer run-script post-install-cmd # Create ini file extension=aerospike.so aerospike.udf.lua_system_path=/path/to/client-php/sys-lua aerospike.udf.lua_user_path=/path/to/client-php/usr-lua
$config = [ "hosts" => [ ["addr" => "127.0.0.1", "port"
=> 3000] ] ]; $db = new Aerospike($config); $key = $db->initKey("infosphere", "characters", 1234); $db->put($key, ["name" => "Scruffy", "Occupation" => "The Janitor"]); $db->put($key, [ "quotes" => [ "I'm Scruffy. The janitor.", "I'm on break.", "Scruffy's gonna die like he lived.", ] ]); $db->get($key, $record, ["name", "quotes"]); $db->close(); simple flow
$db->scan("infosphere", "characters", function ($record) { var_dump($record); }, ["name"]); $where =
Aerospike::predicateBetween("age", 30, 39); $status = $db->query("infosphere", "characters", $where, function ($record) { var_dump($record); }, ["name", "age"]); scans and queries
$status = $db->register('/path/to/my_udf.lua', 'my_udf'); $key = $db->initKey('test', 'demo', 'foo'); $db->apply($key,
"sample", "list_append", ["things", "!!!"]); $status = $db->scanApply("test", "users", "rec_udf", "accumulate", ["balance", "income"], $scan_id); $where = Aerospike::predicateBetween("age", 20, 29); $status = $db->aggregate("test", "users", $where, "mymod", "group_count", ["first_name"], $names); user definied functions
$key = $db->initKey("test", "shows", "Futurama"); $db->put($key, [ "creator" => ["Matt
Groening", "David X Cohen"], "broadcast" => [[1999,2003], [2008,2013]], ]); $characters = new \Aerospike\LDT\LSet($db, $key, 'characters'); $characters->add('Professor Hubert J. Farnsworth'); $characters->addMany([ "Amy Wong", "Hermes Conrad", "Dr. John A. Zoidberg", "Tarunga Leela", "Philip J. Fry", "Bender Bending Rodriguez", "Scruffy", "Cubert Farnsworth” ]); large data types
use cases
None
None
Don’t trust instead, do your own benchmarks in your env
Thanks! @mariuszgil