UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'dTwN9RlaOPZAZV3q16BA/UjQujWrdZc2isUx8N30KUE='
WHERE
key_id = 'a9cac5d54b34c11e19a45a84db69e243a8f19362a0e355e37c68109e1f44692a'
AND (
token = 'dTwN9RlaOPZAZV3q16BA/UjQujWrdZc2isUx8N30KUE='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)