@vGrabko99
html, css, js, php, golang, mysql

Надо ли добавлять в кеш роутинг?

Привет. Вот у меня такой огромный роутинг (добавиться ещё около 70 маршрутов)
router := httprouter.New()
	/*
		:keyApi - апи ключ
		:login  - логин пользователя которого надо авторизовать
		:hash   - md5("/auth/:keyApi/:login/:hash") где :keyApi и :login заменены настоящими значениями
	*/
	//Авторизация, регистрация, доступ//
	router.GET("/auth/:keyApi/:login/:hash", UserAuthViews)
	router.GET("/sekurity/:keyAPI", UserSekurity)
	router.POST("/auth/", UserAuth)
	router.POST("/registration", UserRegistration)
	//Война//
	router.GET("/Battles/Invasion/:keyApi/:token/:hash", BattlesInvasion)
	router.POST("/Battles/Invasion/new/:keyApi/:token/:hash", BattlesInvasionNew)
	router.GET("/Battles/Sanctions/:keyApi/:token/:hash", BattlesSanction)
	router.POST("/Battles/Sanctions/new/:keyApi/:token/:hash", BattlesSanctionNew)
	router.POST("/Battles/Sanction/newProtectorate", BattlesSanctionNewProtectorate)
	router.POST("/Battles/Sanction/newLegion", BattlesSanctionNewLegion)
	/******************************Груповые бои****************************************/
	router.GET("/battleground/:keyApi/:token/:hash", Battleground)
	router.GET("/battleground/main/:keyApi/:token/:hash", BattlegroundDispley)
	router.GET("/battleground/changeRole/:role/:keyApi/:token/:hash", BattlegroundChangeRole)
	router.GET("/battleground/start/:keyApi/:token/:hash", BattlegroundStart)
	router.GET("/battleground/ready/:keyApi/:token/:hash", BattlegroundReady)
	router.GET("/battleground/deseration/:keyApi/:token/:hash", BattlegroundDeseration)
	router.GET("/battleground/attak/:user_attak/:keyApi/:token/:hash", BattlegroundAttak)
	router.GET("/battleground/defense/:user_hospital/:keyApi/:token/:hash", BattlegroundHospital)
	router.GET("/battleground/defense/:user_defense/:keyApi/:token/:hash", BattlegroundDefeense)
	//Мисии//
	router.GET("/Missions/location/:keyApi/:token/:hash", MissionsLocation)
	router.GET("/Missions/location/:id/:keyApi/:token/:hash", MissionsLocationId)
	router.GET("/Missions/location/:id_location/:id_missions/:keyApi/:token/:hash", MissionsLocationOk)
	router.GET("/Missions/hq/:keyApi/:token/:hash", MissionHq)
	router.GET("/Missions/hq/ok/:hqId/:keyApi/:token/:hash", MissionOk)
	router.GET("/Missions/hq/delete/:hqID/:keyApi/:token/:hash", MissionDelete)
	router.GET("/Missions/hq/many/:hqID/:keyApi/:token/:hash", MissionMany)
	//Магазин техники//
	router.GET("/units/index/ground/:page/:keyApi/:token/:hash", UnitsGround)
	router.GET("/units/index/marine/:page/:keyApi/:token/:hash", UnitsMarine)
	router.GET("/units/index/aviation/:page/:keyApi/:token/:hash", UnitsAviation)
	router.GET("/units/index/unique/:page/:keyApi/:token/:hash", UnitsUnique)
	//Чёрный рынок//
	/*возвращает информацио о наёмниках*/
	router.GET("/Blackmarket/Mercenaries/:keyApi/:token/:hash", BlackmarketMercenaries)
	router.GET("/Blackmarket/Mercenaries/:id/:time/:keyApi/:token/:hash", BlackmarketMercenariesNew)
	router.GET("/Blackmarket/Saboteurs/:keyApi/:token/:hash", BlackmarketSaboteurs)
	router.GET("/Blackmarket/Saboteurs/newDiver/:diverId/:keyApi/:token/:hash", BlackmarketSaboteursNewDiver)
	router.GET("/Blackmarket/Saboteurs/newKazarm/:diverId/:keyApi/:token/:hash", BlackmarketSaboteursNewKazarm)
	router.GET("/Blackmarket/Laboratory/:keyApi/:token/:hash", BlackmarketLaboratory)
	router.GET("/Blackmarket/Laboratory/:id/:time/:keyApi/:token/:hash", BlackmarketLaboratoryNew)
	router.GET("/Blackmarket/Contraband/:keyApi/:token/:hash", BlackmarketContraband)
	router.GET("/Blackmarket/Contraband/:id/:keyApi/:token/:hash", BlackmarketContrabandNew)
	router.GET("/Blackmarket/Documents/:keyApi/:token/:hash", BlackmarketDocuments)
	router.GET("/Blackmarket/Documents/:ava/:flags/:keyApi/:token/:hash", BlackmarketDocumentsUpdate)
	router.GET("/Blackmarket/Auction/:keyApi/:token/:hash", BlackmarketAuction)
	router.GET("/Blackmarket/Auction/:gold/:keyApi/:token/:hash", BlackmarketAuctionUpdate)
	//Производство//
	router.GET("/Manufacturing/Factory/:keyApi/:token/:hash", ManufacturingFactory)
	router.GET("/Manufacturing/Factory/evolve/:keyApi/:token/:hash", ManufacturingEvolve)
	router.GET("/Manufacturing/Factory/NewEvolve/:units/:keyApi/:token/:hash", ManufacturingNewEvolve)
	router.GET("/Manufacturing/Factory/New/:keyApi/:token/:hash", ManufacturingNew)
	router.GET("/Manufacturing/Mines/:keyApi/:token/:hash", ManufacturingMines)
	router.GET("/Manufacturing/Mines/Sp/:keyApi/:token/:hash", ManufacturingMinesSp)
	router.GET("/Manufacturing/Mines/TerorAttak/:keyApi/:token/:hash", ManufacturingMinesTerorAttak)
	router.GET("/Manufacturing/Mines/SpContinue/:keyApi/:token/:hash", ManufacturingMinesSpContinue)
	router.GET("/Manufacturing/Mines/new/:keyApi/:token/:hash", ManufacturingMinesNew)
	//Постройки//
	router.GET("/Buildings/Profitable/:keyApi/:token/:hash", BuildingsProfitable)
	router.GET("/Buildings/Profitable/:id/:keyApi/:token/:hash", BuildingsProfitableNew)
	router.GET("/Buildings/Defense/:keyApi/:token/:hash", BuildingsDefense)
	router.GET("/Buildings/Defense/:id/:keyApi/:token/:hash", BuildingsDefenseNew)
	router.GET("/Buildings/Energy/:keyApi/:token/:hash", BuildingsEnergy)
	router.GET("/Buildings/Defense/:id/:keyApi/:token/:hash", BuildingsDefenseNew)
	//Клуб офицеров//
	router.GET("Officerscclub/Resling/:keyApi/:token/:hash", OfficerscResling)
	router.GET("Officerscclub/Roulette/:keyApi/:token/:hash", OfficerscRoulette)
	router.GET("Officerscclub/SpyInterrogation/:keyApi/:token/:hash", OfficerscSpyInterrogation)
	router.GET("Officerscclub/VeteransRiddle/:keyApi/:token/:hash", OfficerscVeteransRiddle)
	router.GET("Officerscclub/WallNewspaper/:keyApi/:token/:hash", OfficerscWallNewspaper)
	//Профиль//
	router.GET("/Profile/Info/:keyApi/:token/:hash", ProfileInfo)
	router.GET("/Profile/Info/:id/:keyApi/:token/:hash", ProfileInfoId)
	router.GET("/Profile/Skills/:keyApi/:token/:hash", ProfileSkills)
	router.GET("/Profile/Achievements/:keyApi/:token/:hash", ProfileAchievements)
	router.GET("/Profile/Property/:keyApi/:token/:hash", ProfileProperty)
	router.GET("/Profile/Booty/:keyApi/:token/:hash", ProfileBooty)
	router.GET("/Profile/Gifts/:keyApi/:token/:hash", ProfileGifts)
	router.GET("/Profile/VipMode/:keyApi/:token/:hash", ProfileVipMode)
	router.GET("/Profile/Statistic/:keyApi/:token/:hash", ProfileStatistic)
	//Зал славы//
	router.GET("/Halloffame/Rating/:keyApi/:token/:hash", HalloffameRating)
	router.GET("/Halloffame/Statistic/:keyApi/:token/:hash", HalloffameStatistic)
	router.GET("/Halloffame/Heroes/:keyApi/:token/:hash", HalloffameHeroes)
	router.GET("/Halloffame/Legions/:keyApi/:token/:hash", HalloffameLegions)
	//Альянс//
	router.GET("/Alliance/Index/:keyApi/:token/:hash", AllianceIndex)
	router.GET("/Alliance/Requests/:keyApi/:token/:hash", AllianceRequests)
	router.GET("/Alliance/Referrals/:keyApi/:token/:hash", AllianceReferrals)
	router.GET("/Alliance/Reinforcement/:keyApi/:token/:hash", AllianceReinforcement)
	router.GET("/Alliance/UnderDefense/:keyApi/:token/:hash", AllianceUnderDefense)
	//Чаты//
	router.GET("/Chat/Public/:keyApi/:token/:hash", ChatPublic)
	router.GET("/Chat/Alliance/:keyApi/:token/:hash", ChatAlliance)
	router.GET("/Chat/Legions/:keyApi/:token/:hash", ChatLegions)
	router.GET("/Chat/Bootcamp/:keyApi/:token/:hash", ChatBootcamp)
	//Банк//
	router.GET("/Bank/Storage/:keyApi/:token/:hash", BankStorage)
	router.GET("/Bank/Gold/:keyApi/:token/:hash", BankGold)
	router.GET("/Bank/Сredit/:keyApi/:token/:hash", BankСredit)
	router.GET("/Bank/Exchanger/:keyApi/:token/:hash", BankExchanger)
	//Почта//
	router.GET("/Mail/Index/:keyApi/:token/:hash", MailIndex)
	router.GET("/Mail/Write/:keyApi/:token/:hash", MailWrite)
	router.GET("/Mail/Contacts/:keyApi/:token/:hash", MailContacts)
	router.GET("/Mail/Ignore/:keyApi/:token/:hash", MailIgnore)
	//Новости//
	router.GET("/News/:keyApi/:token/:hash", News)
	router.GET("/News/AddCommen/:keyApi/:token/:hash", NewsAddCommen)
	//Ежедневный бонус//
	router.GET("/dailyBonus/:keyApi/:token/:hash", dailyBonus)
	//Системные вызовы//
	router.GET("/system/migration", SystemMigration)

На любом пхп фреймворке / классе надо добавлять в кеш такой роутинг иначе сервер от 100 запросов упадёт.
А как с этим на golang? или компилятор компилирует так что не надо кидать в кеш?
Если надо добавлять в кеш то как?
Зарание спасибо.
  • Вопрос задан
  • 577 просмотров
Решения вопроса 2
Fesor
@Fesor
Full-stack developer (Symfony, Angular)
зайдите в документацию по выбранному раутеру:

A compressing dynamic trie (radix tree) structure is used for efficient matching.


То есть эта штука на основе этих правил строит дерево, которое будет лежать в памяти до тех пор, пока у вас живет приложение.

В PHP кэш необходим, так как PHP приложение умирает после каждого запроса и если бы небыло кэша, то разбор этого добра происходил бы на каждый запрос.
Ответ написан
@onepavel
Консультация и разработка мобильных приложений
Хрена себе, я всегда думал, что php для динамической генерации страничек, а тут вот оно как =(
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы