UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'NXooyUOJHM08Ej9A77+VdRkoY2G1wBF2//eiQ1HYMxM='
WHERE
key_id = 'cf9c493ba17874cc4af9bc8858266d06008265915c0951172d46e2966f80d239'
AND (
token = 'NXooyUOJHM08Ej9A77+VdRkoY2G1wBF2//eiQ1HYMxM='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)