Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Lib\Store\CachingPrefetchingTermLookup Class Reference

Prefetches terms from the Cache or via the provided PrefetchingTermLookup if not cached. More...

+ Inheritance diagram for Wikibase\Lib\Store\CachingPrefetchingTermLookup:
+ Collaboration diagram for Wikibase\Lib\Store\CachingPrefetchingTermLookup:

Public Member Functions

 __construct (CacheInterface $cache, PrefetchingTermLookup $lookup, RedirectResolvingLatestRevisionLookup $redirectResolvingRevisionLookup, ContentLanguages $termLanguages, ?int $ttl=null)
 
 prefetchTerms (array $entityIds, array $termTypes, array $languageCodes)
 Loads a set of terms into the buffer.
 
 getPrefetchedTerm (EntityId $entityId, $termType, $languageCode)
 Returns a term that was previously loaded by prefetchTerms.
 
 getPrefetchedAliases (EntityId $entityId, $languageCode)
 Returns terms that were previously loaded by prefetchTerms.
 
 getLabel (EntityId $entityId, $languageCode)
 Gets the label of an Entity with the specified EntityId and language code.
 
 getDescription (EntityId $entityId, $languageCode)
 Gets the description of an Entity with the specified EntityId and language code.
 
 getLabels (EntityId $entityId, array $languageCodes)
 Gets all labels of an Entity with the specified EntityId.
 
 getDescriptions (EntityId $entityId, array $languageCodes)
 Gets all descriptions of an Entity with the specified EntityId.
 

Private Member Functions

 getTerm (EntityId $entityId, string $languageCode, string $termType)
 
 prefetchCachedTerms (array $entityIds, array $termTypes, array $languageCodes)
 
 getCacheKeys (array $entityIds, array $termTypes, array $languageCodes)
 
 prefetchAndCache (array $uncachedIds, array $uncachedTermTypes, array $uncachedLanguageCodes)
 
 getPrefetchedTermsFromLookup (array $entitiesToPrefetch, array $languagesToPrefetch, array $termTypes)
 
 getTermFromLookup (EntityId $entity, string $termType, string $language)
 
 setPrefetchedTermBuffer (EntityId $entityId, string $termType, string $languageCode, $value)
 
 bufferAndCacheExistingTerm (EntityId $entityId, string $termType, string $languageCode, $freshTerm)
 
 bufferAndCacheMissingTerm (EntityId $entityId, string $termType, string $languageCode)
 
 getCacheKey (EntityId $id, string $language, string $termType)
 
 getBufferedOrCachedEntry (EntityId $entityId, string $termType, string $languageCode)
 
 getMultipleTermsByLanguageFromBuffer (EntityId $entityId, string $termType, array $languages)
 
 getMultipleTermsByLanguageFromCache (EntityId $entityId, string $termType, array $languages)
 
 getMultipleTermsByLanguageFromLookup (EntityId $entityId, string $termType, array $languages)
 
 getMultipleTermsByLanguage (EntityId $entityId, string $termType, array $languages)
 
 filterValidTermLanguages (array $languageCodes)
 

Private Attributes

const DEFAULT_TTL = 60
 
const RESOLVED_KEYS = 'resolvedKeys'
 
const UNRESOLVED_IDS = 'unresolvedIds'
 
const KEY_PARTS_MAP = 'keyPartsMap'
 
const UNCACHED_IDS = 'uncachedIds'
 
const UNCACHED_TERM_TYPES = 'uncachedTermTypes'
 
const UNCACHED_LANGUAGE_CODES = 'uncachedLanguageCodes'
 
const ENTITY_ID = 'entityId'
 
const TERM_TYPE = 'termType'
 
const LANGUAGE_CODE = 'languageCode'
 
 $cacheEntryTTL
 
 $cache
 
 $prefetchedTerms
 
 $lookup
 
 $redirectResolvingRevisionLookup
 
 $termLanguages
 

Detailed Description

Prefetches terms from the Cache or via the provided PrefetchingTermLookup if not cached.

Terms requested via the TermLookup methods are also buffered and cached.

CacheInterface determines the medium of caching, and thus the availability (process, server, WAN).

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::__construct ( CacheInterface  $cache,
PrefetchingTermLookup  $lookup,
RedirectResolvingLatestRevisionLookup  $redirectResolvingRevisionLookup,
ContentLanguages  $termLanguages,
?int  $ttl = null 
)

Member Function Documentation

◆ bufferAndCacheExistingTerm()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::bufferAndCacheExistingTerm ( EntityId  $entityId,
string  $termType,
string  $languageCode,
  $freshTerm 
)
private
Parameters
EntityId$entityId
string$termType
string$languageCode
string | string[]$freshTermstring for existing label or description, string[] for existing aliases Should never be null or false
See also
bufferAndCacheMissingTerm

◆ bufferAndCacheMissingTerm()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::bufferAndCacheMissingTerm ( EntityId  $entityId,
string  $termType,
string  $languageCode 
)
private

◆ filterValidTermLanguages()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::filterValidTermLanguages ( array  $languageCodes)
private

◆ getBufferedOrCachedEntry()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getBufferedOrCachedEntry ( EntityId  $entityId,
string  $termType,
string  $languageCode 
)
private

◆ getCacheKey()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getCacheKey ( EntityId  $id,
string  $language,
string  $termType 
)
private

◆ getCacheKeys()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getCacheKeys ( array  $entityIds,
array  $termTypes,
array  $languageCodes 
)
private

◆ getDescription()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getDescription ( EntityId  $entityId,
  $languageCode 
)

Gets the description of an Entity with the specified EntityId and language code.

Since
2.0
Parameters
EntityId$entityId
string$languageCode
Exceptions
TermLookupExceptionfor entity not found
Returns
string|null

Implements Wikibase\DataModel\Services\Lookup\TermLookup.

◆ getDescriptions()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getDescriptions ( EntityId  $entityId,
array  $languageCodes 
)

Gets all descriptions of an Entity with the specified EntityId.

If $languages is given, the result will contain the entries for the requested languages, if they exist.

Since
2.0
Parameters
EntityId$entityId
string[]$languageCodesThe list of languages to fetch
Exceptions
TermLookupExceptionif the entity was not found (not guaranteed).
Returns
string[] descriptions, keyed by language.

Implements Wikibase\DataModel\Services\Lookup\TermLookup.

◆ getLabel()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getLabel ( EntityId  $entityId,
  $languageCode 
)

Gets the label of an Entity with the specified EntityId and language code.

Since
2.0
Parameters
EntityId$entityId
string$languageCode
Exceptions
TermLookupExceptionfor entity not found
Returns
string|null

Implements Wikibase\DataModel\Services\Lookup\TermLookup.

◆ getLabels()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getLabels ( EntityId  $entityId,
array  $languageCodes 
)

Gets all labels of an Entity with the specified EntityId.

The result will contain the entries for the requested languages, if they exist.

Since
2.0
Parameters
EntityId$entityId
string[]$languageCodesThe list of languages to fetch
Exceptions
TermLookupExceptionif the entity was not found (not guaranteed).
Returns
string[] labels, keyed by language.

Implements Wikibase\DataModel\Services\Lookup\TermLookup.

◆ getMultipleTermsByLanguage()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getMultipleTermsByLanguage ( EntityId  $entityId,
string  $termType,
array  $languages 
)
private

◆ getMultipleTermsByLanguageFromBuffer()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getMultipleTermsByLanguageFromBuffer ( EntityId  $entityId,
string  $termType,
array  $languages 
)
private

◆ getMultipleTermsByLanguageFromCache()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getMultipleTermsByLanguageFromCache ( EntityId  $entityId,
string  $termType,
array  $languages 
)
private

◆ getMultipleTermsByLanguageFromLookup()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getMultipleTermsByLanguageFromLookup ( EntityId  $entityId,
string  $termType,
array  $languages 
)
private

◆ getPrefetchedAliases()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getPrefetchedAliases ( EntityId  $entityId,
  $languageCode 
)

Returns terms that were previously loaded by prefetchTerms.

Parameters
EntityId$entityId
string$languageCode
Returns
string[]|false|null The aliases, or false of that entity has no aliases, or null if the term was not yet requested via prefetchTerms().

Implements Wikibase\DataAccess\AliasTermBuffer.

◆ getPrefetchedTerm()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getPrefetchedTerm ( EntityId  $entityId,
  $termType,
  $languageCode 
)

Returns a term that was previously loaded by prefetchTerms.

Parameters
EntityId$entityId
string$termTypeOne of of TermTypes::TYPE_LABEL, TermTypes::TYPE_DESCRIPTION, TermTypes::TYPE_ALIAS
string$languageCode
Returns
string|false|null The term, or false of that term is known to not exist, or null if the term was not yet requested via prefetchTerms().

Implements Wikibase\DataModel\Services\Term\TermBuffer.

◆ getPrefetchedTermsFromLookup()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getPrefetchedTermsFromLookup ( array  $entitiesToPrefetch,
array  $languagesToPrefetch,
array  $termTypes 
)
private

◆ getTerm()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getTerm ( EntityId  $entityId,
string  $languageCode,
string  $termType 
)
private

◆ getTermFromLookup()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::getTermFromLookup ( EntityId  $entity,
string  $termType,
string  $language 
)
private

◆ prefetchAndCache()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::prefetchAndCache ( array  $uncachedIds,
array  $uncachedTermTypes,
array  $uncachedLanguageCodes 
)
private

◆ prefetchCachedTerms()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::prefetchCachedTerms ( array  $entityIds,
array  $termTypes,
array  $languageCodes 
)
private

◆ prefetchTerms()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::prefetchTerms ( array  $entityIds,
array  $termTypes,
array  $languageCodes 
)

Loads a set of terms into the buffer.

The source from which to fetch would typically be supplied to the buffer's constructor.

Parameters
EntityId[]$entityIds
string[]$termTypesThe desired term types, i.e. any of TermTypes::TYPE_LABEL, TermTypes::TYPE_DESCRIPTION, TermTypes::TYPE_ALIAS
string[]$languageCodesThe desired languages.

Implements Wikibase\DataModel\Services\Term\TermBuffer.

◆ setPrefetchedTermBuffer()

Wikibase\Lib\Store\CachingPrefetchingTermLookup::setPrefetchedTermBuffer ( EntityId  $entityId,
string  $termType,
string  $languageCode,
  $value 
)
private
Parameters
EntityId$entityId
string$termType
string$languageCode
string | string[] | false$valuestring for existing label or description, string[] for existing aliases, false for term known to not exist.

Member Data Documentation

◆ $cache

Wikibase\Lib\Store\CachingPrefetchingTermLookup::$cache
private

◆ $cacheEntryTTL

Wikibase\Lib\Store\CachingPrefetchingTermLookup::$cacheEntryTTL
private

◆ $lookup

Wikibase\Lib\Store\CachingPrefetchingTermLookup::$lookup
private

◆ $prefetchedTerms

Wikibase\Lib\Store\CachingPrefetchingTermLookup::$prefetchedTerms
private

◆ $redirectResolvingRevisionLookup

Wikibase\Lib\Store\CachingPrefetchingTermLookup::$redirectResolvingRevisionLookup
private

◆ $termLanguages

Wikibase\Lib\Store\CachingPrefetchingTermLookup::$termLanguages
private

◆ DEFAULT_TTL

const Wikibase\Lib\Store\CachingPrefetchingTermLookup::DEFAULT_TTL = 60
private

◆ ENTITY_ID

const Wikibase\Lib\Store\CachingPrefetchingTermLookup::ENTITY_ID = 'entityId'
private

◆ KEY_PARTS_MAP

const Wikibase\Lib\Store\CachingPrefetchingTermLookup::KEY_PARTS_MAP = 'keyPartsMap'
private

◆ LANGUAGE_CODE

const Wikibase\Lib\Store\CachingPrefetchingTermLookup::LANGUAGE_CODE = 'languageCode'
private

◆ RESOLVED_KEYS

const Wikibase\Lib\Store\CachingPrefetchingTermLookup::RESOLVED_KEYS = 'resolvedKeys'
private

◆ TERM_TYPE

const Wikibase\Lib\Store\CachingPrefetchingTermLookup::TERM_TYPE = 'termType'
private

◆ UNCACHED_IDS

const Wikibase\Lib\Store\CachingPrefetchingTermLookup::UNCACHED_IDS = 'uncachedIds'
private

◆ UNCACHED_LANGUAGE_CODES

const Wikibase\Lib\Store\CachingPrefetchingTermLookup::UNCACHED_LANGUAGE_CODES = 'uncachedLanguageCodes'
private

◆ UNCACHED_TERM_TYPES

const Wikibase\Lib\Store\CachingPrefetchingTermLookup::UNCACHED_TERM_TYPES = 'uncachedTermTypes'
private

◆ UNRESOLVED_IDS

const Wikibase\Lib\Store\CachingPrefetchingTermLookup::UNRESOLVED_IDS = 'unresolvedIds'
private

The documentation for this class was generated from the following file: