Subversion Repository Public Repository

Nextrek

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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php namespace Illuminate\Cache;

class RedisTaggedCache extends TaggedCache {

	/**
	 * Store an item in the cache indefinitely.
	 *
	 * @param  string  $key
	 * @param  mixed   $value
	 * @return void
	 */
	public function forever($key, $value)
	{
		$this->pushForeverKeys($namespace = $this->tags->getNamespace(), $key);

		$this->store->forever(sha1($namespace).':'.$key, $value);
	}

	/**
	 * Remove all items from the cache.
	 *
	 * @return void
	 */
	public function flush()
	{
		$this->deleteForeverKeys();

		parent::flush();
	}

	/**
	 * Store a copy of the full key for each namespace segment.
	 *
	 * @param  string  $namespace
	 * @param  string  $key
	 * @return void
	 */
	protected function pushForeverKeys($namespace, $key)
	{
		$fullKey = $this->getPrefix().sha1($namespace).':'.$key;

		foreach (explode('|', $namespace) as $segment)
		{
			$this->store->connection()->lpush($this->foreverKey($segment), $fullKey);
		}
	}

	/**
	 * Delete all of the items that were stored forever.
	 *
	 * @return void
	 */
	protected function deleteForeverKeys()
	{
		foreach (explode('|', $this->tags->getNamespace()) as $segment)
		{
			$this->deleteForeverValues($segment = $this->foreverKey($segment));

			$this->store->connection()->del($segment);
		}
	}

	/**
	 * Delete all of the keys that have been stored forever.
	 *
	 * @param  string  $foreverKey
	 * @return void
	 */
	protected function deleteForeverValues($foreverKey)
	{
		$forever = array_unique($this->store->connection()->lrange($foreverKey, 0, -1));

		if (count($forever) > 0)
		{
			call_user_func_array(array($this->store->connection(), 'del'), $forever);
		}
	}

	/**
	 * Get the forever reference key for the segment.
	 *
	 * @param  string  $segment
	 * @return string
	 */
	protected function foreverKey($segment)
	{
		return $this->getPrefix().$segment.':forever';
	}

}

Commits for Nextrek/Aiba_backup/vendor/laravel/framework/src/Illuminate/Cache/RedisTaggedCache.php

Diff revisions: vs.
Revision Author Commited Message
1464 MOliva picture MOliva Tue 13 Oct, 2020 11:16:56 +0000