-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35794ee
commit 9a344fd
Showing
7 changed files
with
622 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
include("SimpleWorker.class.php"); | ||
|
||
$name = "testRedis.php-".microtime(true); | ||
|
||
$sw = new SimpleWorker('config_sw.ini'); | ||
$sw->debug_enabled = true; | ||
|
||
$project_id = ""; # using default project_id from config | ||
$zipName = "code/$name.zip"; | ||
|
||
$zipFile = SimpleWorker::zipDirectory(dirname(__FILE__)."/worker_examples/php_redis", $zipName, true); | ||
|
||
$res = $sw->postCode($project_id, 'testRedis.php', $zipName, $name); | ||
$task_id = $sw->postTask($project_id, $name); | ||
echo "task_id = $task_id \n"; | ||
sleep(10); | ||
$details = $sw->getTaskDetails($project_id, $task_id); | ||
print_r($details); | ||
|
||
if ($details->status != 'queued'){ | ||
$log = $sw->getLog($project_id, $task_id); | ||
print_r($log); | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<? | ||
|
||
/** | ||
* Peer class used for entity saving without any list functionality | ||
*/ | ||
class redis_peer | ||
{ | ||
protected $name_space; | ||
|
||
public function __construct() | ||
{ | ||
$this->name_space = get_class($this); | ||
} | ||
|
||
/** | ||
* @return php_redis | ||
*/ | ||
public function get_connection() | ||
{ | ||
return redis_pool::get('master'); | ||
} | ||
|
||
public function next_id() | ||
{ | ||
return $this->get_connection()->inc($this->name_space . 'pk'); | ||
} | ||
|
||
public function last_id() | ||
{ | ||
return $this->get_connection()->get($this->name_space . 'pk'); | ||
} | ||
|
||
public function insert( $data ) | ||
{ | ||
$data['id'] = $this->next_id(); | ||
$this->get_connection()->set($this->name_space . 'item' . $data['id'], $data); | ||
return $data['id']; | ||
} | ||
|
||
public function update( $id, $data ) | ||
{ | ||
$data = array_merge($this->get_by_id($id), $data); | ||
$this->get_connection()->set($this->name_space . 'item' . $id, $data); | ||
} | ||
|
||
public function get_by_id( $id ) | ||
{ | ||
return $this->get_connection()->get($this->name_space . 'item' . $id); | ||
} | ||
|
||
public function delete( $id ) | ||
{ | ||
return $this->get_connection()->delete($this->name_space . 'item' . $id); | ||
} | ||
} |
Oops, something went wrong.