Skip to content
Snippets Groups Projects
Commit d807ff56 authored by Jonas Kjærandsen's avatar Jonas Kjærandsen
Browse files

Added a differentiator the the cache elements (an identifier prepending the...

Added a differentiator the the cache elements (an identifier prepending the key such as id:, hash:, etc.)
parent d9bee51f
No related branches found
No related tags found
1 merge request!2Merge react-branch into main.
......@@ -30,7 +30,7 @@ func UploadFileRetrieve(c *gin.Context) {
return
}
value, err := utils.Conn.Do("GET", id)
value, err := utils.Conn.Do("GET", "file:"+id)
if value == nil {
if err != nil {
fmt.Println("Error:" + err.Error())
......@@ -47,7 +47,7 @@ func UploadFileRetrieve(c *gin.Context) {
}
// Add the data to the database
response, err := utils.Conn.Do("SETEX", id, 300, fileData)
response, err := utils.Conn.Do("SETEX", "file:"+id, 300, fileData)
if err != nil {
fmt.Println("Error adding data to redis:" + err.Error())
}
......@@ -115,7 +115,6 @@ func UploadFile(c *gin.Context) {
// use file contents to fetch file name, associate it with the "file" form header.
part, err := writer.CreateFormFile("file", file2.Filename)
if err != nil {
log.Println(err)
}
......
......@@ -18,7 +18,7 @@ func HashIntelligence(c *gin.Context) {
hash := c.Query("hash")
value, err := utils.Conn.Do("GET", hash)
value, err := utils.Conn.Do("GET", "hash:"+hash)
if value == nil {
if err != nil {
fmt.Println("Error:" + err.Error())
......@@ -33,7 +33,7 @@ func HashIntelligence(c *gin.Context) {
}
// Add the data to the database
response, err := utils.Conn.Do("SETEX", hash, 300, hashInt)
response, err := utils.Conn.Do("SETEX", "hash:"+hash, 300, hashInt)
if err != nil {
fmt.Println("Error adding data to redis:" + err.Error())
}
......
......@@ -17,7 +17,7 @@ func UrlIntelligence(c *gin.Context) {
var URLint []byte
//var URLint utils.APIresponseResult
value, err := utils.Conn.Do("GET", url)
value, err := utils.Conn.Do("GET", "url:"+url)
if value == nil {
if err != nil {
fmt.Println("Error:" + err.Error())
......@@ -32,7 +32,7 @@ func UrlIntelligence(c *gin.Context) {
// Add the data to the redis backend.
if completeInt {
response, err := utils.Conn.Do("SETEX", url, 300, URLint)
response, err := utils.Conn.Do("SETEX", "url:"+url, 300, URLint)
if err != nil {
fmt.Println("Error adding data to redis:" + err.Error())
}
......
......@@ -88,7 +88,7 @@ func CodeToToken(code string) (token string, authenticated bool) {
hash := tokenToHash(oauth2Token.AccessToken)
// Add to the database
_, err = utils.Conn.Do("SETEX", hash, (oauth2Token.Expiry.Unix() - time.Now().Unix()), marshalledTokens)
_, err = utils.Conn.Do("SETEX", "user:"+hash, (oauth2Token.Expiry.Unix() - time.Now().Unix()), marshalledTokens)
if err != nil {
fmt.Println("Error adding data to redis:" + err.Error())
return "", false
......@@ -120,7 +120,7 @@ func CodeToToken(code string) (token string, authenticated bool) {
}
func getAuth(hash string) (token string, err bool) {
value, error := utils.Conn.Do("GET", hash)
value, error := utils.Conn.Do("GET", "user:"+hash)
if value == nil {
if error != nil {
fmt.Println("Error:" + error.Error())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment