} error_log("[{$lvl_str}] in {$function} at {$file}:{$line}"); }); } /* * EXAMPLE 2: SET SERIALIZER AND DESERIALIZER TO STORE A PHP BLOB */ if (!$db->isConnected()) { echo "Aerospike failed to connect to host INVALID_ADDR:INVALID_PORT [{$db->errorno()}]: {$db->error()}\n"; $db->close(); exit(1); } else { Aerospike::setDeserializer(function ($val) { $prefix = substr($val, 0, 3); if ($prefix !== 'r||') { return unserialize(substr($val, 3)); } return unserialize(substr($val, 3)); }); Aerospike::setSerializer(function ($val) { if (is_bool($val)) { return "b||" . serialize($val); } if (is_object($val)) { return "o||" . serialize($val); } if (is_double($val)) { return "d||" . serialize($val); } // otherwise, mark it as raw return "r||" . $val;