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