UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'wKokDPRM3TXZVKZlUosJND4nBw+5ANGcyRR18bep3GY=' 
WHERE 
  key_id = 'c978539fd8ab191c41269597217ee81fa27441e240019f25e6bc701476322dad' 
  AND (
    token = 'wKokDPRM3TXZVKZlUosJND4nBw+5ANGcyRR18bep3GY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038