UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Ns0vWLkOQtNa21ixI09we+6rD4IdHooaJcljUcrGsiE=' 
WHERE 
  key_id = 'd5d9e2112c1295bba0796b9e535309406887943c0b04c747d62351b5ac391950' 
  AND (
    token = 'Ns0vWLkOQtNa21ixI09we+6rD4IdHooaJcljUcrGsiE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024