Created
January 3, 2012 20:37
-
-
Save szepeshazi/1556812 to your computer and use it in GitHub Desktop.
Test script to show how Elgg 1.8+ handles asynchronous parallel metadata updates.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once (dirname(__FILE__)) . '/engine/start.php'; | |
$options = array( | |
'type' => 'object', | |
'subtype' => 'paraleltest', | |
'limit' => 1 | |
); | |
$access = elgg_set_ignore_access(true); | |
$entities = elgg_get_entities($options); | |
if (is_array($entities) && !empty($entities)) { | |
$entity = $entities[0]; | |
if (isset($entity->impressions)) { | |
$entity->impressions = $entity->impressions + 1; | |
} else { | |
$entity->impressions = 1; | |
} | |
error_log("Counter is now {$entity->impressions}"); | |
} else { | |
// Pick any user to be the owner of the object | |
$users = elgg_get_entities(array('type' => 'user')); | |
$user = $users[0]; | |
$object = new ElggObject(); | |
$object->subtype = 'paraleltest'; | |
$object->owner_guid = $user->guid; | |
$object->container_guid = $user->guid; | |
$object->access_id = ACCESS_PUBLIC; | |
$object->save(); | |
$object->impressions = 0; | |
$object->save(); | |
error_log("Test object created"); | |
} | |
elgg_set_ignore_access($access); | |
?> |
Author
szepeshazi
commented
Jan 3, 2012
- Drop this script into your Elgg installation's root directory.
- Hit http://your-elgg-site/parallel_test.php in your browser a couple of times, and watch the log. Counter should increase one by one.
- Run "ab -n 100 -c 10 http://your-elgg-site/parallel_test.php" and watch the log. You'll see at some point the integer property turning into an array.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment