/** * Create the variation object hash if it doesnt already exist. * * @access public * @param string $test_id * @param string $variation_id * @return void */ public function createVariationIfDne($test_id, $variation_id) { $this->getClient(); // create a timestamp $now = new \DateTime('now', new \DateTimeZone('UTC')); $now = $now->format('U'); // create variation if DNE if (!$this->client->hexists('variation:' . $variation_id, 'pageviews')) { // add variation hash key to list $this->client->rpush('variation.ids', $variation_id); // create variation hash $this->client->hmset('variation:' . $variation_id, array('id' => $variation_id, 'test_id' => $test_id, 'pageviews' => 0, 'wins' => 0, 'timestamp' => $now)); // associate variation to test $this->client->rpush('test:' . $test_id . ':variation.ids', $variation_id); } }