File: MemcachedTaggedCacheTest.php

package info (click to toggle)
php-laravel-framework 6.20.14%2Bdfsg-2%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 10,932 kB
  • sloc: php: 122,752; sh: 136; javascript: 45; makefile: 44
file content (54 lines) | stat: -rw-r--r-- 2,070 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php

namespace Illuminate\Tests\Integration\Cache;

use Illuminate\Support\Facades\Cache;

/**
 * @group integration
 */
class MemcachedTaggedCacheTest extends MemcachedIntegrationTest
{
    public function testMemcachedCanStoreAndRetrieveTaggedCacheItems()
    {
        $store = Cache::store('memcached');

        $store->tags(['people', 'artists'])->put('John', 'foo', 2);
        $store->tags(['people', 'authors'])->put('Anne', 'bar', 2);

        $this->assertSame('foo', $store->tags(['people', 'artists'])->get('John'));
        $this->assertSame('bar', $store->tags(['people', 'authors'])->get('Anne'));

        $store->tags(['people', 'artists'])->put('John', 'baz');
        $store->tags(['people', 'authors'])->put('Anne', 'qux');

        $this->assertSame('baz', $store->tags(['people', 'artists'])->get('John'));
        $this->assertSame('qux', $store->tags(['people', 'authors'])->get('Anne'));

        $store->tags('authors')->flush();
        $this->assertNull($store->tags(['people', 'authors'])->get('Anne'));

        $store->tags(['people', 'authors'])->flush();
        $this->assertNull($store->tags(['people', 'artists'])->get('John'));
    }

    public function testMemcachedCanStoreManyTaggedCacheItems()
    {
        $store = Cache::store('memcached');

        $store->tags(['people', 'artists'])->putMany(['John' => 'foo', 'Jane' => 'bar'], 2);

        $this->assertSame('foo', $store->tags(['people', 'artists'])->get('John'));
        $this->assertSame('bar', $store->tags(['people', 'artists'])->get('Jane'));

        $store->tags(['people', 'artists'])->putMany(['John' => 'baz', 'Jane' => 'qux']);

        $this->assertSame('baz', $store->tags(['people', 'artists'])->get('John'));
        $this->assertSame('qux', $store->tags(['people', 'artists'])->get('Jane'));

        $store->tags(['people', 'artists'])->putMany(['John' => 'baz', 'Jane' => 'qux'], -1);

        $this->assertNull($store->tags(['people', 'artists'])->get('John'));
        $this->assertNull($store->tags(['people', 'artists'])->get('Jane'));
    }
}