UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ai0QyrsI84enrNgKV47Gg1Mo92EhIJga/2iHoNPG2Os=' 
WHERE 
  key_id = '638551cc71271c676c3692bf323a127151723308673e88e20ec117305059ef8a' 
  AND (
    token = 'ai0QyrsI84enrNgKV47Gg1Mo92EhIJga/2iHoNPG2Os=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00030