UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '5ccXpLHBP7wLWPl1inDQvWl5qWdOGWBdxD6XUEt6XZg='
WHERE
key_id = 'a4d18045e0e2093048b8535580f75e0c3effd6c9502525eb273b5cdf3d2ea15d'
AND (
token = '5ccXpLHBP7wLWPl1inDQvWl5qWdOGWBdxD6XUEt6XZg='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)