diff --git a/README.md b/README.md index 069f5f0..d1ba34d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Via Composer ``` json { "require": { - "square1/wordpressed": "dev-master" + "square1/wordpressed": "0.1.*" } } ``` @@ -36,18 +36,6 @@ $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()); @@ -55,28 +43,8 @@ print_r($wp->getQueryLog()); $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; } diff --git a/composer.json b/composer.json index 501ffe8..d55eded 100644 --- a/composer.json +++ b/composer.json @@ -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.*", diff --git a/src/Manager.php b/src/Manager.php index fc62721..b52cb71 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -1,8 +1,6 @@ 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); - } } diff --git a/src/Post.php b/src/Post.php index 19374ed..0f30eab 100644 --- a/src/Post.php +++ b/src/Post.php @@ -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;