Example #1
0
 public function testRecountDomainCountsRecache()
 {
     \Cache::tags('domains')->flush();
     // Recount items in domain
     $domain = Domain::cache('en');
     $domain->recount('comments_total', 'recountComments');
     $this->assertTrue($domain->comments_total === '3');
     // But in cache have old value.
     $domain_in_cache = Domain::cache('en');
     $this->assertTrue($domain_in_cache->comments_total === '0');
     $domain->recache();
     // No select query here.
     $domain = Domain::cache('en');
     $this->assertTrue($domain->comments_total === '3');
 }
Example #2
0
 public function run()
 {
     \Websanova\EasyCache\Models\Domain::truncate();
     \DB::table('websanova_easycache_domains')->insert(['slug' => 'en', 'name' => 'English']);
     \DB::table('websanova_easycache_domains')->insert(['slug' => 'fr', 'name' => 'French']);
     \Websanova\EasyCache\Models\Item::truncate();
     \DB::table('websanova_easycache_items')->insert(['domain_id' => 1, 'slug' => 'one', 'name' => 'One', 'description' => 'Item One.', 'status' => 'active', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
     \DB::table('websanova_easycache_items')->insert(['domain_id' => 1, 'slug' => 'two', 'name' => 'Two', 'description' => 'Item Two.', 'status' => 'active', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
     \DB::table('websanova_easycache_items')->insert(['domain_id' => 1, 'slug' => 'three', 'name' => 'Three', 'description' => 'Item Three.', 'status' => 'deleted', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
     \DB::table('websanova_easycache_items')->insert(['domain_id' => 2, 'slug' => 'four', 'name' => 'Four', 'description' => 'Item Four.', 'status' => 'active', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
     \DB::table('websanova_easycache_items')->insert(['domain_id' => 2, 'slug' => 'five', 'name' => 'Five', 'description' => 'Item Five.', 'status' => 'deleted', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
     \Websanova\EasyCache\Models\Comment::truncate();
     \DB::table('websanova_easycache_comments')->insert(['domain_id' => 1, 'item_id' => 1, 'slug' => 'comment 1', 'title' => 'Comment One', 'body' => 'This is comment one.', 'status' => 'active', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
     \DB::table('websanova_easycache_comments')->insert(['domain_id' => 1, 'item_id' => 1, 'slug' => 'comment 2', 'title' => 'Comment Two', 'body' => 'This is comment two.', 'status' => 'active', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
     \DB::table('websanova_easycache_comments')->insert(['domain_id' => 1, 'item_id' => 1, 'slug' => 'comment 3', 'title' => 'Comment Three', 'body' => 'This is comment three.', 'status' => 'deleted', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
     \DB::table('websanova_easycache_comments')->insert(['domain_id' => 1, 'item_id' => 2, 'slug' => 'comment 4', 'title' => 'Comment Four', 'body' => 'This is comment four.', 'status' => 'active', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
 }
Example #3
0
<?php

Route::get('easy-cache/test', function () {
    \Config::set('app.domain', \Websanova\EasyCache\Models\Domain::find(1));
    //dd(\Websanova\EasyCache\Models\Item::getAll());
    $items = config('app.domain')->getAllActiveItems();
    $items->flush();
    return 'Test';
});