UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Qy1t0dMxPYVa8bA+NYIF6JRgxJt9Hb50x8m0UAweIN0=' 
WHERE 
  key_id = '51d631e1551c0ea52c11311d0c71b8965ed750402fe98ec5597989066481f8f1' 
  AND (
    token = 'Qy1t0dMxPYVa8bA+NYIF6JRgxJt9Hb50x8m0UAweIN0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00017