UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'bjXr7IVMYZZuvmwI9kLpoCSPQ5pCaG5uzJHsEdjHfwo=' 
WHERE 
  key_id = '687fbcf10a9cfb3b7de16596948edbff85f01cd4a32b1a82887b277e0b7501bb' 
  AND (
    token = 'bjXr7IVMYZZuvmwI9kLpoCSPQ5pCaG5uzJHsEdjHfwo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040