Ағылшыншамен салыстырыңыз: абзацты басыңыз — түпнұсқа терезеде ашылады. Абзац астындағы EN түймесі оны мәтін ішінде көрсетеді.
Мазмұны
Кіріспе
Компьютерлік бағдарламалауда, теріс кэш – "теріс" жауаптарды, яғни сәтсіздіктерді сақтайтын кэш. Яғни, бағдарлама сәтсіздік екенін көрсететін нәтижені, оның себебі түзетілгеннен кейін де есте сақтайды. Көбінесе теріс кэш – дизайн шешімі, бірақ ол бағдарламалық қате болуы да мүмкін.
In computer programming, negative cache is a cache that also stores "negative" responses, i. e. failures. This means that a program remembers the result indicating a failure even after the cause has been corrected. Usually negative cache is a design choice, but it can also be a software bug.
Мысалдар
Желіде қолжетімсіз болған кезде бетті жүктеуге тырысатын веб-браузерді қарастырайық. Браузерге қате коды келіп түседі және ол пайдаланушыға сұралған беттің орнына осы қате туралы хабарламаны көрсетуі мүмкін. Дегенмен, браузердің қате хабарламасын бет кэшіне орналастыруы дұрыс емес, себебі бұл пайдаланушы желі қалпына келгеннен кейін де сол бетті жүктеуге тырысқанда қате қайтадан көрсетілуіне әкеледі. Қате хабарламасы беттің URL-і бойынша кэштелуі тиіс емес; браузер бетті сәтті жүктемегенше, пайдаланушы бетті жүктеуге тырысқан сайын, браузер жаңа әрекет жасауы керек. Жағымсыз кэштердің көнерген жағы – пайдаланушы мәселені шешуге көп күш жұмсауы мүмкін, ал түпкі себебін анықтап, жойғаннан кейін де қате жоғалмайды. Кейбір жағдайларда сәтсіздік жағдайларын кэштеу қажет. Мысалы, DNS кэштеу атау серверлері жағымсыз жауаптарды жағымды жауаптармен бірге есте сақтауын талап етеді. Егер беделді атау сервері жағымсыз жауап берсе, атаудың жоқ екенін көрсетеді, бұл кэштеледі. Жағымсыз жауап қолданба деңгейінде сәтсіздік ретінде қарастырылуы мүмкін; алайда, оны кэштейтін атау сервері үшін бұл сәтсіздік емес. Жағымсыз және жағымды кэштеу уақытын тәуелсіз түрде реттеуге болады.
Consider a web browser which attempts to load a page while the network is unavailable. The browser will receive an error code indicating the problem, and may display this error message to the user in place of the requested page. However, it is incorrect for the browser to place the error message in the page cache, as this would lead it to display the error again when the user tries to load the same page even after the network is back up. The error message must not be cached under the page's URL; until the browser is able to successfully load the page, whenever the user tries to load the page, the browser must make a new attempt. A frustrating aspect of negative caches is that the user may put a great effort into troubleshooting the problem, and then after determining and removing the root cause, the error still does not vanish. There are cases where failure like states must be cached. For instance, DNS requires that caching nameservers remember negative responses as well as positive ones. If an authoritative nameserver returns a negative response, indicating that a name does not exist, this is cached. The negative response may be perceived as a failure at the application level; however, to the nameserver caching it, it is not a failure. The cache times for negative and positive caching may be tuned independently.
Сипаттама
Теріс кэш әдетте, егер қателік қымбатқа түссе және қате жағдайы пайдаланушының араласуынсыз автоматты түрде туындаса ғана қажет болады. Бұл пайдаланушыға қателік себебін анықтауға мүмкіндік бермейді: олар барлық мүмкін нәрсені түзгеніне қарамастан, бағдарлама жұмыс істеуден бас тарта береді. Қателік кэштелген жағдайда, бағдарлама қателік себебін сипаттағаннан бөлек, кэшті тазалау үшін не істеу керектігін нақты көрсетуі керек. Мұндай жағдайларда теріс кэш – дизайнның дұрыс емес үлгісінің мысалы болып табылады. Кэште сақталған жазбалардың мерзімі біткен жағдайда теріс кэш жаңаруы мүмкін.
A negative cache is normally only desired if failure is very expensive and the error condition raises automatically without user's action. It creates a situation where the user is unable to isolate the cause of the failure: despite fixing everything they can think of, the program still refuses to work. When a failure is cached, the program should provide a clear indication of what must be done to clear the cache, in addition to a description of the cause of the error. In such conditions a negative cache is an example of a design anti pattern. Negative cache still may recover if the cached records expires.