UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'QM3tY6euepw4B+6WMPatRwu7C9kBoAJHXvCdafEqqCA=' 
WHERE 
  key_id = 'b42764c48a7179fb72d2f8cd0b6e6c56f7db89270724341612456510622cac21' 
  AND (
    token = 'QM3tY6euepw4B+6WMPatRwu7C9kBoAJHXvCdafEqqCA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00048