Redis
sanannen tsarin adana bayanai ne mai ƙarfi da ake amfani da shi sosai don adanawa da sarrafa layukan yanar gizo a aikace-aikacen gidan yanar gizo masu inganci. A cikin wannan labarin, za mu bincika yadda ake haɗa kai Redis
don Laravel yin amfani da fa'idodinsa wajen haɓaka sarrafa bayanai da sarrafa jerin gwano.
Amfani Redis
kamar yadda Cache
a cikin Laravel
Amfanin cikin Redis Cache
Laravel
Redis
babban ma'ajin bayanai ne mai sauri da inganci, yana ba da damar dawo da bayanai cikin sauri da adanawa.- Yana goyan bayan ajiyar bayanai na wucin gadi da caching, rage lokacin samun damar bayanai da haɓaka amsa aikace-aikacen.
Redis
yana ba da fasali kamar cache ƙarewar atomatik da ma'ajin ƙwaƙwalwar ajiya, inganta ma'ajin bayanan wucin gadi.
Haɗin kai Redis Cache
Laravel
Mataki 1: Shigar Redis
Server kuma tabbatar kana da sabuwar sigar Laravel.
Mataki 2: Shigar da kunshin ta hanyar Mawaƙi don ba da damar haɗi zuwa. predis/predis
Laravel Redis
Mataki 3: Sanya Redis
haɗin cikin fayil ɗin. config/cache.php
Da zarar an haɗa cikin nasara, zaku iya amfani da Laravel ayyukan kamar cache()
, remember()
, forget()
don aiki tare da Redis tushen caching.
Amfani Redis
kamar yadda Queue
a cikin Laravel
Amfanin Redis Queue
cikin Laravel
Redis
yana ba da ingantaccen layi mai inganci don sarrafa ayyuka masu nauyi da asynchronous a aikace-aikace.Queue
yana taimakawa rage lokacin sarrafa buƙatun kuma yana haɓaka haɓakar aikace-aikacen, sarrafa ayyuka da yawa a lokaci guda.Redis
yana goyan bayan tsarin Buga-Subscribe, yana ba da damar aiwatar da tsarin sanarwa na ainihin lokaci a cikin aikace-aikacen.
Haɗin Redis Queue
kai Laravel
Mataki 1: Ƙirƙiri haɗi zuwa Redis cikin config/queue.php
fayil ɗin.
Mataki 2: Ƙayyade ayyuka kuma yi amfani da dispatch()
ayyukan don ƙara ayyuka zuwa jerin gwano.
Tare da Redis
azaman Queue
, zaku iya tura ayyukan asynchronous cikin jerin gwano don ingantaccen aiki, rage lokacin amsawa, da haɓaka aikin aikace-aikacen gabaɗaya.
Misali:
Misali, a cikin Laravel aikace-aikacen da ke sarrafa duka ayyuka na daidaitawa kamar sarrafa oda da ayyuka asynchronous kamar aika sanarwar imel, ta amfani da Redis
yadda cache
zai iya adana sakamakon ayyuka na dogon lokaci don sarrafa sauri. Bugu da ƙari, yin aiki Redis
kamar yadda Queue
zai ba ku damar aiwatar da ayyukan da ba su dace ba da kyau kamar aika imel, rage lokacin amsawa, da haɓaka aikin aikace-aikacen gabaɗaya.
Ta hanyar haɗawa Redis kamar Cache
kuma Queue
a cikin Laravel, kuna haɓaka iyawar sarrafa bayanai da sarrafa jerin gwano, yayin inganta ƙwarewar mai amfani da amsa buƙatu cikin sauri a cikin aikace-aikacenku.