Skip to content

Commit

Permalink
Make cache non-case-sensitive (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
man90es authored Jun 18, 2024
1 parent 80e0e34 commit 39b4309
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions handlers/GetAdventurerSearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"

"bdo-rest-api/cache"
"bdo-rest-api/models"
Expand All @@ -28,6 29,9 @@ func GetAdventurerSearch(w http.ResponseWriter, r *http.Request) {
return
}

// All names are non-case-sensitive, so this will allow to utilise cache better
query = strings.ToLower(query)

// Look for cached data, then run the scraper if needed
data, status, date, expires, found := profileSearchCache.GetRecord([]string{region, query, fmt.Sprint(searchType), fmt.Sprint(page)})
if !found {
Expand Down
4 changes: 4 additions & 0 deletions handlers/GetGuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 3,7 @@ package handlers
import (
"encoding/json"
"net/http"
"strings"

"bdo-rest-api/cache"
"bdo-rest-api/models"
Expand All @@ -25,6 26,9 @@ func GetGuild(w http.ResponseWriter, r *http.Request) {
return
}

// All names are non-case-sensitive, so this will allow to utilise cache better
name = strings.ToLower(name)

// Look for cached data, then run the scraper if needed
data, status, date, expires, found := guildProfilesCache.GetRecord([]string{region, name})
if !found {
Expand Down
4 changes: 4 additions & 0 deletions handlers/GetGuildSearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"

"bdo-rest-api/cache"
"bdo-rest-api/models"
Expand All @@ -27,6 28,9 @@ func GetGuildSearch(w http.ResponseWriter, r *http.Request) {
return
}

// All names are non-case-sensitive, so this will allow to utilise cache better
name = strings.ToLower(name)

// Look for cached data, then run the scraper if needed
data, status, date, expires, found := guildSearchCache.GetRecord([]string{region, name, fmt.Sprint(page)})
if !found {
Expand Down

0 comments on commit 39b4309

Please sign in to comment.