Skip to content

Commit

Permalink
Memecache working as intended
Browse files Browse the repository at this point in the history
  • Loading branch information
pdweinstein committed Aug 13, 2019
1 parent 5202838 commit d78fc53
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
36 changes: 24 additions & 12 deletions lib/pre.php
Expand Up @@ -10,24 +10,25 @@
if ( $location != 'local' ) {

$memcache = new Memcache;
$memcache->addServer( $mhost, $mport );
$memcache->connect( $mhost, $mport );

if ( $posts = $memcache->get( 'latest' )) {
if ( $latest = $memcache->get( 'latest' )) {

$posts = $memcache->get( 'latest' );
$latest = $memcache->get( 'latest' );
$latestDate = $memcache->get( 'latest_date' );
$githubEvents = $memcache->get( 'github' );
$recent = $memcache->get( 'flickr_recent' );
$info = $memcache->get( 'flickr_info' );
$books = $memcache->get( 'goodreads' );
$instaData = $memcache->get( 'instagram' );
$tweets = $memcache->get( 'tweets' );
$book = $memcache->get( 'goodreads' );
$instaObj = $memcache->get( 'instagram' );
$tweets = $memcache->get( 'twitter' );

}

}

if (( $location == 'local' ) OR
( !$posts = $memcache->get( 'latest' ))) {
( !$latest = $memcache->get( 'latest' ))) {

//$seti = new RPC;

Expand All @@ -53,13 +54,15 @@
$instaObj = $elsewhere->getInstaPosts( $instaToken, 1 );
$tweets = json_decode( $twitter->setGetfield( $getfield )->buildOauth( $twitterURL, $requestMethod )->performRequest() );

$book['link'] = $books[0]->link;
$book['title'] = $books[0]->title;

if( $location != 'local' ) {

$memcache->set( 'latest', $latest, MEMCACHE_COMPRESSED, 3600 );
$memcache->set( 'github', $githubEvents, MEMCACHE_COMPRESSED, 3600 );
$memcache->set( 'flickr_recent', $recent, MEMCACHE_COMPRESSED, 3600 );
$memcache->set( 'flickr_info', $info, MEMCACHE_COMPRESSED, 3600 );
$memcache->set( 'goodreads', $books, MEMCACHE_COMPRESSED, 3600 );
$memcache->set( 'goodreads', $book, MEMCACHE_COMPRESSED, 3600 );
$memcache->set( 'instagram', $instaObj, MEMCACHE_COMPRESSED, 3600 );
$memcache->set( 'twitter', $tweets, MEMCACHE_COMPRESSED, 3600 );

Expand Down Expand Up @@ -94,8 +97,17 @@
// Reset our pointer to the top of the array
reset( $posts );

// Pull our winner
$latest = key( $posts );
$latestDate = gmdate( "M d Y", $posts[$latest] );
if (( $location == 'local' ) OR
( !$latest = $memcache->get( 'latest' ))) {

// Pull our winner
$latest = key( $posts );
$latestDate = gmdate( "M d Y", $posts[$latest] );

$memcache->set( 'latest', $latest, MEMCACHE_COMPRESSED, 3600 );
$memcache->set( 'latest_date', $latestDate, MEMCACHE_COMPRESSED, 3600 );
$memcache->set( 'latest_post', $post, MEMCACHE_COMPRESSED, 3600 );

}

?>
7 changes: 3 additions & 4 deletions www/index.php
Expand Up @@ -86,13 +86,12 @@
<li><a href=\"https://www.goodreads.com/author/show/193451.Paul_Weinstein\" alt\"Goodreads\">Goodreads</a> <ul> <li> Currently reading
");

$book = $books[0];
$template->outputHTML( "<a href='" .$book->link. "' alt='" .$book->title. "'> " .$book->title. " </a>");
$template->outputHTML( "<a href='" .$book['link']. "' alt='" .$book['title']. "'> " .$book['title']. " </a>");
$template->outputHTML("
</li></ul>
<li><a href=\"https://www.facebook.com/pdweinstein\" alt\"Facebook\">Facebook</a></li>
");

/*
$postData = "";
$userPosts = $fb->get("/526081044/feed", $accessToken);
$postBody = $userPosts->getDecodedBody();
Expand All @@ -110,7 +109,7 @@
}
}
}

*/
$template->outputHTML("
<li><a href=\"https://www.flickr.com/photos/pdweinstein\" alt\"Flickr\">Flickr</a><ul><li>
");
Expand Down

0 comments on commit d78fc53

Please sign in to comment.