I was wondering if I would have problems if I base64(or other) encode an entire sql query, for example:
SELECT t.* FROM (SELECT chat.id as tempId, UuidFromBin(uuid) as id,userFrom,userTo,objDateTime,msg,msgType,idExternal,readed FROM chat WHERE talk=UuidToBin(xxxx-xxxxxxx-xxxxxxx-xxxxxxx) and 650 IN (userTo,userFrom) ORDER BY tempId DESC LIMIT 50) t ORDER BY t.tempId ASC
Base64 Encoded:
U0VMRUNUIHQuKiBGUk9NIChTRUxFQ1QgY2hhdC5pZCBhcyB0ZW1wSWQsIFV1aWRGcm9tQmluKHV1aWQpIGFzIGlkLHVzZXJGcm9tLHVzZXJUbyxvYmpEYXRlVGltZSxtc2csbXNnVHlwZSxpZEV4dGVybmFsLHJlYWRlZCBGUk9NIGNoYXQgV0hFUkUgdGFsaz1VdWlkVG9CaW4oeHh4eC14eHh4eHh4LXh4eHh4eHgteHh4eHh4eCkgYW5kIDY1MCBJTiAodXNlclRvLHVzZXJGcm9tKSBPUkRFUiBCWSB0ZW1wSWQgREVTQyBMSU1JVCA1MCkgdCBPUkRFUiBCWSB0LnRlbXBJZCBBU0M=
I noticed that comparing the length of the original string with the base64 encoded string, the last one was considerably increased, but some articles on internet says that redis keys can't have spaces, so encoding it would be a workaround.
Continuing... What do you guys thinks about using this string as a Redis key and as its value, I would store the entire query response as a simple json string.
This way, before hitting database, I would always check if that same query was recently executed. What do you guys think about performance in this kind of approach? Will I have problems or is this a good way of giving some breath to my database servers?