UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ZA8+8tvfUEgtupSqw6ce25DMgXYEKkrJyEv4gG1mkd4='
WHERE
key_id = 'd8972237078c34576e84033ccd1ecc50b2d7228d520780cdbb5dd0575cf78834'
AND (
token = 'ZA8+8tvfUEgtupSqw6ce25DMgXYEKkrJyEv4gG1mkd4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)