Fetch a data from the cache by the tag(s)

@param  string | array $tags
@param  bool           $byIntersect
@return array
557571
public function getByTag($tags, $byIntersect = false) {
		if (is_array($tags)) {
			$tags = array_map([$this, 'prepareTag'], array_values($tags));
		} else {
			$tags = $this->prepareTag($tags);
		}
		
		$tagData = $this->getTagData($tags, $byIntersect);
		
		if ($tagData === null) {
			return [];
		}
		
		return $this->getBackend()->getMany($tagData);
	}
899880
public function scopeWithAnyTag($query, $tagNames)
	{
		if(!is_array($tagNames)) {
			$tagNames = func_get_args();
			array_shift($tagNames);
		}
		$tagNames = static::$taggingUtility->makeTagArray($tagNames);

		$model = static::$taggingUtility->tagModelString();
		$tagids = $model::byTagNames($tagNames)->lists('id')->all();

		$className = $query->getModel()->getMorphClass();
		$primaryKey = $this->getKeyName();

		$tags = Tagged::whereIn('tag_id', $tagids)
			->where('taggable_type', $className)
			->lists('taggable_id');

		return $query->whereIn($this->getTable().'.'.$primaryKey, $tags);
	}
1023501
public function invalidateTags(array $tags)
    {
        if (!$this->cache instanceof TagAwareAdapterInterface) {
            throw new \RuntimeException('Cannot invalidate tags on a cache
            implementation that does not implement the TagAwareAdapterInterface.');
        }

        try {
            return $this->cache->invalidateTags($tags);
        } catch (InvalidArgumentException $e) {
            return false;
        }
    }
87036
public function tag($ids, $tags)
    {
        $namespace = $this->getNamespace() . '/tag';

        return $this->ontraport->put($namespace, $this->toArray([
            'ids' => implode(',', (array) $ids),
            'add_list' => implode(',', (array) $tags),
        ]));
    }
853419
public static function matchTagsWithSortOrder(array $tags1, array $tags2)
    {
        if (count(self::diffTags($tags1, $tags2, true)) == 0 &&
            count(self::diffTags($tags2, $tags1, true)) == 0)
            return true;

        return false;

    }
966728
public function has(string $key, array $tags): bool 
    {
        return $this->cache->tags($tags)->has($key);
    }
1325205
public function get($cacheGroupKey, array $params = [], $tags = null)
    {
        // Make sure caching is enabled
        if (!$this->isCachingEnabled()) {
            return;
        }

        // Retrieve cache group settings
        $cacheGroup = $this->getCacheGroup($cacheGroupKey);

        // Set cache tag to group name
        if (!$tags) {
            $tags = $cacheGroupKey;
        }

        if (empty($cacheGroup) || (empty($cacheGroup['active']) || empty($cacheGroup['key']))) {
            return;
        }

        // Generate cache key
        $cacheKey = $this->generateCacheKey($cacheGroup['key'], $params);

        return IlluminateCache::tags($tags)->get($cacheKey);
    }
224992
public function delete($key, $tags = '')
    {
        $cache = app('cache');

        if (!empty($tags)) {
            $tags = json_decode($tags, true);
            $cache = $cache->tags($tags);
        } else {
            unset($tags);
        }

        $success = $cache->forget($key);

        return response()->json(compact('success'));
    }
1045590
public static function getOrSet($key, \Closure $closure, int $ttl = null, array $tags = [])
    {
        $item = self::getCacheService()->user()->getItem(self::key($key));
        if ($item->isHit()) {
            return $item->get();
        }

        $result = $closure();
        $item->set($result);
        if ($ttl) {
            $item->expiresAfter($ttl);
        }
        if ($tags && $item instanceof CacheItem) {
            $item->tag($tags);
        }
        self::getCacheService()->user()->save($item);
        return $result;
    }
122632
protected function getDocBlockResponses(array $tags)
    {
        $responseTags = array_values(
            array_filter($tags, function ($tag) {
                return $tag instanceof Tag && strtolower($tag->getName()) === 'response';
            })
        );

        if (empty($responseTags)) {
            return;
        }

        return array_map(function (Tag $responseTag) {
            preg_match('/^(\d{3})?\s?([\s\S]*)$/', $responseTag->getContent(), $result);

            $status = $result[1] ?: 200;
            $content = $result[2] ?: '{}';

            return new JsonResponse(json_decode($content, true), (int) $status);
        }, $responseTags);
    }
1207025
public function scopeWithAnyTag( $query, $tags )
    {
        $tags = $this->makeTagsArray($tags);

        $tag_ids = Tag::whereIn('tag', $tags)
                      ->pluck('id');

        $taggable_ids = Taggable::whereIn('tag_id', $tag_ids)
                                ->where('taggable_type', $query->getModel()->getMorphClass())
                                ->pluck('taggable_id');

        return $query->whereIn($this->getTable() .'.id', $taggable_ids);
    }
506300
public function getTopTagIds(array $sourceIds = [], int $limit = null, bool $withCount = false): array
    {
        /** @var Model $model */
        $model = $this->framework->getAdapter(Model::class);

        $tagIds = $model->getRelatedValues($this->sourceTable, $this->sourceField, $sourceIds);
        $tagIds = \array_map('intval', $tagIds);

        if (0 === \count($tagIds)) {
            return [];
        }

        $helper = [];

        // Create the helper array with tag occurrences
        foreach ($tagIds as $tagId) {
            ++$helper[$tagId];
        }

        // Sort the helper array descending
        \arsort($helper);

        // Strip the count data
        if (!$withCount) {
            $helper = \array_keys($helper);
        }

        return \array_slice($helper, 0, $limit, $withCount);
    }
82233
protected function doFetch(array $ids)
    {
        if ( ! $ids) {
            return [];
        }

        return $this->redis->hmget($this->namespace, $this->keys($ids));
    }
250514
public function tag($abstracts, $tags)
    {
        $tags = is_array($tags) ? $tags : array_slice(func_get_args(), 1);

        foreach ($tags as $tag) {
            if (! isset($this->tags[$tag])) {
                $this->tags[$tag] = [];
            }

            foreach ((array) $abstracts as $abstract) {
                $this->tags[$tag][] = $abstract;
            }
        }
    }
146807
public function withTags(array $tags)
    {
        Assertion::allIsInstanceOf($tags, TagInterface::class);
        Assertion::lessOrEqualThan(\count($tags), VideoInterface::TAG_MAX_COUNT);

        $instance = clone $this;

        $instance->tags = $tags;

        return $instance;
    }
698745
public function getIdsMatchingTags($tags = array())
    {
        $first = true;
        $ids = array();
        foreach ($tags as $tag) {
            $res = $this->_query("SELECT DISTINCT(id) AS id FROM tag WHERE name='$tag'");
            if (!$res) {
                return array();
            }
            $rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
            $ids2 = array();
            foreach ($rows as $row) {
                $ids2[] = $row['id'];
            }
            if ($first) {
                $ids = $ids2;
                $first = false;
            } else {
                $ids = array_intersect($ids, $ids2);
            }
        }
        $result = array();
        foreach ($ids as $id) {
            $result[] = $id;
        }
        return $result;
    }
752449
private function extractTagData(array $values, ?array &$addTagData, ?array &$removeTagData): array
    {
        $addTagData = $removeTagData = [];
        foreach ($values as $id => $value) {
            foreach ($value['tag-operations']['add'] as $tag => $tagId) {
                $addTagData[$tagId][] = $id;
            }

            foreach ($value['tag-operations']['remove'] as $tag => $tagId) {
                $removeTagData[$tagId][] = $id;
            }

            unset($values[$id]['tag-operations']);
        }

        return $values;
    }