Posts

Showing posts with the label streams

Query logging and profiling in MongoDB

In my previous blog post I mentioned that the 1.5.0 release of the MongoDB driver for PHP has improved notification support using the PHP Notification API , and showed off a fairly useless (but fun) progress bar. Now its time for a little bit more practical examples using this system: Query logging and profiling. Those of you who clicked through to the github Pull Request may have noticed the long long description of the API and noticed all the different " MONGO_STREAM_NOTIFY_LOG_xxx " constants it included.. When instantiating MongoClient you can pass in " Driver Options " using the 3rd argument. Currently there is only one available Driver Option: " context ". The  context  key takes a Stream Context , and is assigned to all of the underlaying connections the driver creates - which means you can set any of the Socket Context  and SSL Context  options and it will Just Work (maaan.. that saved me a ton of work.. Not needing to implement any of ...

PHP Stream Notifications ❤ MongoDB

PHP Streams have several pretty nifty features that most people don't really know about; Filters , Wrappers , Context , and Notifications . Documenting these is a bit difficult, and getting the user to discover these features is even more problematic, as these things usually live outside of the normal path (function reference). Maybe I'll blog about these things in the future, but for now I want to talk about the Stream (context) Notifications  - or more specifically; Stream Notifications in the MongoDB extension for PHP. The Stream Notifications are essentially pretty simple: when a stream does something, it notifies something (a callback function) that it did something (notification codes, importance, message code, ..). Since this feature is a little neglected and people don't seem to know about it, this "something happened" isn't really a lot of things. When PHP reads from the http stream it will tell you if it came across a " redirect header ...