UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'KUybGw6SdvibdD3gHiXt+313PHYISmCFoI9TsfXakEA=' 
WHERE 
  key_id = '8df4319a5896429dc573d03fca00b17e8100827aac6b373b4cd014d21ea77e60' 
  AND (
    token = 'KUybGw6SdvibdD3gHiXt+313PHYISmCFoI9TsfXakEA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034