Indexing for Improved Cache Search
The purpose of using an index is to optimize speed and performance in finding relevant data against cache search. For searching purposes, all searchable attributes should be indexed. Without an index, the search would scan every data, which would require considerable time and computing power. The additional computer storage required to store the index, as well as the considerable increase in the time required for an update to take place, are traded off for the time saved during information retrieval.
NCache internally uses indexing in different modules to boost the performance of internal operations.
Indice di ricerca nella cache
NCache provides the Cache Searching Index to boost the execution of queries on the cache. For searching purposes, all that is needed to be done is to just index all the searchable attributes. NCache will not search the non-indexed attribute from the cache because it has to traverse through the whole cache to find related data which will affect the cache performance.
Also, indexes are defined against the actual data types of the cached items. Through the indexing, NCache knows what kind of data will be stored and it will store it in a searchable way.
NCache fornisce due modi per definire gli indici.
- Indice predefinito (indice statico)
- Indice di runtime (indice dinamico)
Indice predefinito (indice statico)
Note:
Questa funzionalità è disponibile anche in NCache Professional.
Note:
Si consiglia di evitare l'indicizzazione di campi non necessari poiché l'indicizzazione ha un sovraccarico di memoria e prestazioni.
To search custom class objects in a clustered cache, the query indexes for that class need to be defined in advance. In this way, the cache will save that data in the form where it can be easily queried. You can define indexes through the following processo di configurazione. Gli indici possono essere configurati per i membri di dati primitivi pubblici, privati e protetti.
Note:
Gli indici sono supportati solo sui tipi di valore. I tipi di riferimento non possono essere indicizzati.
Indexes can be defined through configuration before the cache start. In case you want to define new indexes through configuration, the cache needs to be stopped first and restarted after modifications for deploying changes. The relevant data added to the cache subsequently is automatically indexed. This data can be queried easily in the future.
avvertimento
Contrassegnare esplicitamente un tipo di riferimento come indicizzabile genererà un'eccezione.
Indice di runtime (indice dinamico)
If there are attributes in an application that are defined and used at runtime, then runtime indexing should be used. For example, there may be some calculated values assigned to a product related to its sales. When any product is purchased by any customer, the sale details are saved in the cache for generating daily reports of sales trends through cached values later. This value is defined at runtime so it’s the runtime attribute of the product.
NCache will automatically create indexes for data that are added by the cache client. It means that indexes do not need to be configured before using them for runtime attributes.
Quando si definiscono gli indici a livello di codice, le classi oi campi possono essere contrassegnati come indicizzabili utilizzando attributi personalizzati nel codice dell'applicazione. Una volta contrassegnati, tutte le proprietà ei campi primitivi vengono automaticamente indicizzati. Poiché potrebbe non essere necessario indicizzare tutti i campi, puoi anche escluderli dall'indicizzazione. Oltre a indicizzare l'intera classe, hai anche la flessibilità di definire gli indici in modo selettivo solo per i campi desiderati.
L'indice di runtime può essere ulteriormente classificato nei seguenti tipi:
- Indice del gruppo
- Indice dei tag
- Indice dei tag denominati
Indice del gruppo
Gli elementi possono essere classificati nella cache utilizzando gruppi. NCache ti consente di interrogare i dati nella cache in base ai gruppi, a causa dei quali anche i gruppi devono essere indicizzati. Quando vengono aggiunti dati a un gruppo che non esiste già nella cache, viene creato un nuovo indice per il gruppo. Tutti i dati appartenenti a questo gruppo vengono quindi assegnati allo stesso indice per la ricerca.
Indice dei tag
One or more identification marks can be associated with cache items. These identification marks are called tags. Through tags, the user can associate keywords(s) with cache items. A collection of cached items can be found and removed from the cache by specifying tags too. Tags are only allowed in string format. For every new tag, a new tag entry will be created in the tag index and all related cached items will be associated with that index.
Indice dei tag denominati
If there is a need to use a high level of tagging where tags can have different data types or names and the requirement is to query data related to a specific type of tag, then Named Tags should be used.
“Named Tags" is the enhancement of "Tags". Named tags allows the user to store additional information (of any type) required to query the object stored as a string. For example, the "Highest-Sale-Time" named tag with a value of time can be stored when any product sale is the highest in a whole day. Named tags allow indexing the data according to required attributes at runtime. Later on, a query can be constructed using named tags to fetch the desired result set. Multiple named tags can be associated with one cached item and vice versa.
When data is added with a named tag that does not exist in the cache, a new index is created for this new named tag. All the related data will be assigned to that index for searching.
Unlike Tag, the named tag index can be defined for all primitive types, strings, and date time. So there is more flexibility to add a wide range of searchable data with different data types.
If there are multiple applications that are sharing the same cache and all of them are supposed to add named tags, then make sure that the same named tags have homogenous data types, e.g., if one client is adding the named tag "ProductID" with String data type, then all other clients should add values of "ProductID" in String format not in Integer or other for the same cache.
Indice di sfratto
Lo sfratto è una funzione utile in NCache, dove quando la cache è piena decide di eliminare i dati esistenti in modo da accogliere i dati in arrivo. In questo scenario, l'eliminazione può semplificare le operazioni della cache mantenendo il limite della dimensione della cache rimuovendo una percentuale configurata di dati.
NCache prevede diverse politiche per lo sfratto. Queste politiche decidono quali dati verranno eliminati quando la cache è piena. NCache prevede le seguenti politiche di sfratto:
- Sfratto basato sulla priorità
Note:
Questa funzionalità è disponibile anche in NCache Professional.
For Priority Based Eviction, the index is kept for priority from high to low and when the cache is full, the eviction thread selects keys from index with low priority and evicts them from cache.
- Usato meno di recente (LRU)
For the Least Recently Used (LRU), eviction index is kept for the time of usage of keys and when the cache is full, the eviction thread selects keys from the index that are least recently used and evicts them from the cache.
- Utilizzo meno frequente (LFU)
Per Least Frequently Used (LFU), l'indice di eliminazione viene mantenuto per il numero di utilizzo delle chiavi e quando la cache è piena, il thread di eliminazione seleziona dall'indice le chiavi utilizzate meno frequentemente e le rimuove dalla cache.
Note:
Per eseguire lo sfratto, NCache mantiene l'indice di sfratto per i dati della cache per lo sfratto.
Indice di scadenza
La scadenza è una proprietà allegata a ciascun elemento che viene memorizzato nella cache. Questa proprietà è allegata a ciascun oggetto in modo che ogni oggetto della cache possa essere valutato in base alla sua età, questa età dell'oggetto deciderà la sua data di scadenza. Quando l'oggetto di scadenza viene invalidato, l'elemento associato viene rimosso dalla cache.
NCache mantiene il DateTime
Indice di scadenza per le chiavi della cache al fine di rimuoverle in modo efficiente alla scadenza. Il gestore della scadenza fa scadere gli elementi dopo l'intervallo di pulizia.
Intervallo pulito è l'intervallo periodico dopo il quale gli elementi scaduti vengono rimossi dalla cache. L'intervallo di pulizia per una cache può essere modificato nelle impostazioni di configurazione.
After a clean interval has elapsed, the expiration manager gets keys from the index and expired items are removed from the cache. After removing expired items from the cache, the expiration thread sleeps for the “clean interval duration” specified in the cache configuration. NCache fornisce due tipi di scadenze spiegate in Strategie di invalidazione dei dati:
- Scadenza assoluta
- Scadenza scorrevole
Vedere anche
Configura indici di query
Rimuovi-QueryIndex
espulsione
Condivisione dei dati di runtime