Avoid fatal error when the cache data is not a string

#6256