Use a SELECT query in set() to predetermine whether a key exists.

This somewhat reverts commit d6ddb12c20a646204bee1d5c3d749e1b22783f05.
Add detailed explaination why SELECT query is useful.