<?php require_once 'SharedConfigurations.php'; require_once 'Predisql.php'; $database_connection['name'] = "backupdb"; $redisql = new Predisql_Client($database_connection, $single_server, NULL); //$redisql->echo_command = 1; //$redisql->echo_response = 1; //$redisql->mysql_echo_command = 1; $keys = $redisql->keys("*"); foreach ($keys as $key) { $type = $redisql->type($key); if ($type != "index" && $type != "string") { $backup_table = "backup_{$key}"; echo "BACKUP: {$key} TO REDISQL TABLE: {$backup_table}<br/>"; try { $redisql->dropTable($backup_table); } catch (Exception $e) { } $redisql->createTableFromRedisObject($backup_table, $key); $mysql_backup_table = "redis_backup_" . $key . "_" . gmdate("M_d_Y", time()); echo "DUMP: {$backup_table} TO MYSQL TABLE: {$mysql_backup_table}<br/>"; $redisql->dumpToMysql($backup_table, $mysql_backup_table); echo "DROP REDISQL TABLE: {$backup_table}<br/>"; $redisql->dropTable($backup_table); } }
<?php require_once 'SharedConfigurations.php'; require_once 'Predisql.php'; $redisql = new Predisql_Client($database_connection, $single_server); //$redisql->echo_command = 1; //$redisql->echo_response = 1; $drop = @$_GET['drop']; if ($drop) { try { $redisql->dropTable("user"); } catch (Exception $e) { } try { $redisql->dropTable("user_address"); } catch (Exception $e) { } try { $redisql->dropTable("user_payment"); } catch (Exception $e) { } echo "<br/>"; echo "<br/>"; } echo "First populate user:id:[name,age,status] <br/>"; echo "Then populate user:id:address[street,city,zipcode] <br/>"; echo "Then populate user:id:payment[type,account] <br/>"; $redisql->set("user:1:name", "bill"); $redisql->set("user:1:age", " 33"); $redisql->set("user:1:status", " member"); $redisql->set("user:1:address:street", "12345 main st");
//$redisql->mysql_echo_command = 1; $one_hour = 3600; $one_day = 86400; $now = gettimeofday(true); $yesterday = $now - $one_day; $two_days_ago = $now - 2 * $one_day; $user_id = 44; $z_name = "tweets"; $z_obj = $z_name . ":" . $user_id; $mysql_archive_table = $z_name . "_archive"; $temp_mysql_table = "user_" . gmdate("M_d_Y", time()); $drop = @$_GET['drop']; if ($drop) { $redisql->del($z_obj); try { $redisql->dropTable($temp_mysql_table); } catch (Exception $e) { } $redisql->m_query("delete from {$mysql_archive_table};"); } populate_tweets($redisql, $z_name, $user_id, $yesterday, $two_days_ago, 0); $zset_cache = new Zset_Cache($redisql); $zset_cache->archive($z_name, $user_id, $two_days_ago, $yesterday); $display_archive_query = "select * from {$mysql_archive_table} order by score"; $result = $redisql->m_query($display_archive_query); echo "<br/>"; echo "MYSQL ARCHIVE TABLE<br/>"; while ($row = $redisql->m_fetch_assoc($result)) { echo " " . "DATE: <strong>" . $row['score'] . "</strong> " . "TWEET: <strong>" . $row['tweets'] . "</strong><br/>"; } $redisql->m_free_result($result);
To call this repeatedly (and each time dropping the Redisql table, use: "?table=employee_data&drop=1" */ $database_connection['name'] = "test"; // Mysql DatabaseName $redisql = new Predisql_Client($database_connection, $single_server, NULL); $redisql->echo_command = 1; $redisql->echo_response = 1; $redisql->mysql_echo_command = 1; $table = @$_GET['table']; if (!$table) { echo "this script makes the mysql table designated by the URL variable \"table=\" schemaless<br/>"; return; } $drop = @$_GET['drop']; if ($drop) { try { $redisql->dropTable($table); } catch (Exception $e) { } } try { $redisql->importFromMysql($table); } catch (Exception $e) { } $redisql->dump($table); $wildcard = $table . ':*'; $redisql->denormalize($table, $wildcard); echo "HGETALL {$table}:1<br/>"; print_r($redisql->hgetall("{$table}:1")); echo "<br/>";