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