set_transient fails if the value has more than 60.000 characters

I found the problem! Everything was ok with the transient, the problem was that I’m using php’s substr() to cut an object property value if exceeds maximum characters. When in that string there was an accented character there was a problem with the encoding. So the serialized collection had an encoding issue at character 60000… I fixed it using substr_mb() and specifying UTF-8 as encoding.

Hard to debug this issue since wpdb doesn’t throw any error when there is an encoding problem.