UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'RdZT9qsRFCnNdIKkZd9yyDUmasISPJ1dszrCN8YNg3o='
WHERE
key_id = 'c33a78a788c8364964764cd98fb8a4682d87ab7fc20f0e048077df89e7ce751a'
AND (
token = 'RdZT9qsRFCnNdIKkZd9yyDUmasISPJ1dszrCN8YNg3o='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)