Skip to content

Commit

Permalink
get ready for 0.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaranmaher committed Sep 1, 2014
1 parent eda5e19 commit afdd82d
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 99 deletions.
38 changes: 3 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Via Composer
``` json
{
"require": {
"square1/wordpressed": "dev-master"
"square1/wordpressed": "0.1.*"
}
}
```
Expand All @@ -36,47 +36,15 @@ $wp = new Manager([
'password' => 'some_secure_password',
]);

//Enable file cache
$wp->cache([
'driver' => 'file',
'path' => '/tmp/wordpressed',
'connection' => null
]);

//Enable apc cache
$wp->cache([
'driver' => 'apc'
]);

//Get Query Log
print_r($wp->getQueryLog());

//Get post by id
$post = Post::find(12345);
echo $post->post_name;

//Get and cache post by id with meta
$posts = Post::with(
array('meta' => function ($q) {
$q->remember(1);
}
))->remember(1)->find(1234);
foreach ($posts as $post) {
echo $post->post_name;
}

//Cache callback with ttl
$posts = $wp->remember('cache-key', 1, function() {
return Post::status('publish')->take(3)->get();
});
foreach ($posts as $post) {
echo $post->post_name;
}

//Cache callback forever
$posts = $wp->rememberForever('cache-key-forever', function() {
return Post::status('publish')->take(3)->get();
});
//Get post by id with meta
$posts = Post::with('meta')->find(1234);
foreach ($posts as $post) {
echo $post->post_name;
}
Expand Down
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"require": {
"php": ">=5.4.0",
"illuminate/database": "4.2.*",
"illuminate/cache": "4.2.*",
"illuminate/filesystem": "4.2.*"
},
"require-dev": {
"squizlabs/php_codesniffer": "1.*",
Expand Down
61 changes: 0 additions & 61 deletions src/Manager.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php namespace Square1\Wordpressed;

use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Cache\CacheManager as CacheManager;
use \Illuminate\Filesystem\Filesystem as Filesystem;

class Manager
{
Expand All @@ -26,11 +24,6 @@ class Manager
*/
private $capsule;

/**
* @var Illuminate\Database\Capsule\Manager
*/
private $cache;

/**
* Connect to the Wordpress database
*
Expand All @@ -52,58 +45,4 @@ public function getQueryLog()
{
return $this->capsule->getConnection()->getQueryLog();
}

/**
* Cache callback
*
* @param string $key The cache key
* @param int $ttl The time in minutes
* @param Closure $callback The callback query
*
* @return array
*/
public function remember($key, $ttl, $callback)
{
return $this->cache->remember($key, $ttl, $callback);
}

/**
* Cache callback, remember forever
*
* @param string $key The cache key
* @param Closure $callback The callback query
*
* @return array
*/
public function rememberForever($key, $callback)
{
return $this->cache->rememberForever($key, $callback);
}

/**
* Enable cache
*
* @param array $config The cache config
*/
public function enableCache($config)
{
$container = $this->capsule->getContainer();

if ($config['driver'] == 'file') {
$container->offsetGet('config')
->offsetSet('cache.driver', 'file');
$container->offsetGet('config')
->offsetSet('cache.path', $config['path']);
$container->offsetGet('config')
->offsetSet('cache.connection', $config['connection']);
$container['files'] = new Filesystem();

} elseif ($config['driver'] == 'apc') {
$container->offsetGet('config')->offsetSet('cache.driver', 'apc');
}

$cacheManager = new CacheManager($container);
$this->cache = $cacheManager->driver();
$this->capsule->setCacheManager($cacheManager);
}
}
1 change: 0 additions & 1 deletion src/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class Post extends Eloquent
public function newQuery($excludeDeleted = true)
{
$query = parent::newQuery($excludeDeleted);

$query->where('post_type', $this->postType);

return $query;
Expand Down

0 comments on commit afdd82d

Please sign in to comment.